PERFORCE change 29853 for review
Juli Mallett
jmallett at FreeBSD.org
Sat Apr 26 21:21:22 PDT 2003
http://perforce.freebsd.org/chv.cgi?CH=29853
Change 29853 by jmallett at 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 <machine/cpufunc.h>
#include <machine/cpuregs.h>
#include <machine/frame.h>
+#include <machine/md_var.h>
+#include <machine/pte.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
@@ -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();
}
More information about the p4-projects
mailing list