From owner-p4-projects@FreeBSD.ORG Sat Apr 26 21:21:21 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 4645F37B404; Sat, 26 Apr 2003 21:21:21 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D0D2137B401 for ; Sat, 26 Apr 2003 21:21:20 -0700 (PDT) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6920243F85 for ; Sat, 26 Apr 2003 21:21:20 -0700 (PDT) (envelope-from jmallett@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id h3R4LK0U037248 for ; Sat, 26 Apr 2003 21:21:20 -0700 (PDT) (envelope-from jmallett@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id h3R4LJLf037239 for perforce@freebsd.org; Sat, 26 Apr 2003 21:21:19 -0700 (PDT) Date: Sat, 26 Apr 2003 21:21:19 -0700 (PDT) Message-Id: <200304270421.h3R4LJLf037239@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jmallett@freebsd.org using -f From: Juli Mallett To: Perforce Change Reviews Subject: PERFORCE change 29853 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Apr 2003 04:21:22 -0000 http://perforce.freebsd.org/chv.cgi?CH=29853 Change 29853 by jmallett@jmallett_dalek on 2003/04/26 21:20:30 Lies, placeholders, and a PTE description. Affected files ... .. //depot/projects/mips/sys/mips/include/md_var.h#5 edit .. //depot/projects/mips/sys/mips/include/pmap.h#6 edit .. //depot/projects/mips/sys/mips/include/pte.h#1 add .. //depot/projects/mips/sys/mips/mips/machdep.c#11 edit .. //depot/projects/mips/sys/mips/mips/pmap.c#7 edit .. //depot/projects/mips/sys/mips/sgimips/machdep_sgimips.c#11 edit Differences ... ==== //depot/projects/mips/sys/mips/include/md_var.h#5 (text+ko) ==== @@ -28,6 +28,9 @@ #ifndef _MACHINE_MD_VAR_H_ #define _MACHINE_MD_VAR_H_ +extern vm_offset_t kstack0; +extern vm_paddr_t kstack0_phys; + void cpu_halt(void); void cpu_reset(void); void mips_init(void); ==== //depot/projects/mips/sys/mips/include/pmap.h#6 (text+ko) ==== @@ -34,6 +34,8 @@ struct pmap { struct pmap_statistics pm_stats; + int pm_asid; + int pm_asidgen; }; typedef struct pmap *pmap_t; @@ -45,7 +47,9 @@ extern vm_offset_t virtual_avail; extern vm_offset_t virtual_end; +void pmap_bootstrap(void); vm_offset_t pmap_kextract(vm_offset_t); +vm_offset_t pmap_steal_memory(vm_size_t); #define pmap_resident_count(pm) ((pm)->pm_stats.resident_count) #define vtophys(va) pmap_kextract((vm_offset_t)(va)) ==== //depot/projects/mips/sys/mips/mips/machdep.c#11 (text+ko) ==== @@ -44,12 +44,16 @@ struct pcpu pcpu0; +vm_offset_t kstack0; +vm_paddr_t kstack0_phys; + void mips_init(void) { struct pcpu *pc; proc_linkup(&proc0, &ksegrp0, &kse0, &thread0); + thread0.td_kstack = kstack0; pc = &pcpu0; pc->pc_curthread = &thread0; } ==== //depot/projects/mips/sys/mips/mips/pmap.c#7 (text+ko) ==== @@ -37,6 +37,8 @@ #include #include #include +#include +#include #include #include @@ -56,10 +58,15 @@ vm_offset_t virtual_avail; vm_offset_t virtual_end; +pt_entry_t *kptemap; +vm_size_t kptemapsize; + struct msgbuf *msgbufp; int pmap_pagedaemon_waken; +static vm_offset_t pmap_bootstrap_alloc(vm_size_t); + #define UNIMPL() \ printf("%s unimplemented at %s:%d\n", __func__, __FILE__, __LINE__) @@ -312,3 +319,78 @@ { UNIMPL(); } + +void +pmap_bootstrap(void) +{ + int i; + + kptemapsize = PAGE_SIZE; /* XXX placeholder */ + kptemap = pmap_bootstrap_alloc(sizeof *kptemap * kptemapsize); + + /* + * Allocate a kernel stack for thread0. + */ + kstack0_phys = pmap_bootstrap_alloc(KSTACK_PAGES * PAGE_SIZE); + kstack0 = kstack0_phys; + + /* + * Calculate the first and last available physical addresses. + */ + avail_start = phys_avail[0]; + for (i = 0; phys_avail[i + 2] != 0; i += 2) + ; + avail_end = phys_avail[i + 1]; +} + +/* + * Allocate a physical page of memory directly from the phys_avail map. + * Can only be called from pmap_bootstrap before avail start and end are + * calculated. + */ +static vm_offset_t +pmap_bootstrap_alloc(vm_size_t size) +{ + vm_offset_t pa; + int i; + + size = round_page(size); + for (i = 0; phys_avail[i + 1] != 0; i += 2) { + if (phys_avail[i + 1] - phys_avail[i] < size) + continue; + pa = phys_avail[i]; + phys_avail[i] += size; + return (pa); + } + panic("pmap_bootstrap_alloc"); +} + +vm_offset_t +pmap_steal_memory(vm_size_t size) +{ + vm_size_t bank_size; + vm_offset_t pa, va; + + size = round_page(size); + + bank_size = phys_avail[1] - phys_avail[0]; + while (size > bank_size) { + int i; + for (i = 0; phys_avail[i+2]; i+= 2) { + phys_avail[i+0] = phys_avail[i+2]; + phys_avail[i+1] = phys_avail[i+3]; + } + phys_avail[i+0] = 0; + phys_avail[i+1] = 0; + if (!phys_avail[0]) + panic("pmap_steal_memory: out of memory"); + bank_size = phys_avail[1] - phys_avail[0]; + } + + pa = phys_avail[0]; + phys_avail[0] += size; + + va = MIPS_PHYS_TO_KSEG1(pa); + bzero(va, size); + return (va); +} ==== //depot/projects/mips/sys/mips/sgimips/machdep_sgimips.c#11 (text+ko) ==== @@ -141,5 +141,6 @@ printf("avail memory = %d (%d MB)\n", ctob(availmem), ctob(availmem) / (1024 * 1024)); + pmap_bootstrap(); mips_init(); }