summaryrefslogtreecommitdiffstats
path: root/sys/powerpc
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2008-04-16 23:28:12 +0000
committermarcel <marcel@FreeBSD.org>2008-04-16 23:28:12 +0000
commita200693e6156c16781fa375ecb5e2ea9a6b6cae2 (patch)
treea0b99cbc9c791431b929dd66bd1a5d0c36415ff7 /sys/powerpc
parente3127074b582dbc674999dc16d5b709d6fecfa41 (diff)
downloadFreeBSD-src-a200693e6156c16781fa375ecb5e2ea9a6b6cae2.zip
FreeBSD-src-a200693e6156c16781fa375ecb5e2ea9a6b6cae2.tar.gz
Allocate a stack (with optional guard pages) for thread0 and
switch to it before calling mi_startup().
Diffstat (limited to 'sys/powerpc')
-rw-r--r--sys/powerpc/aim/locore.S3
-rw-r--r--sys/powerpc/aim/machdep.c23
-rw-r--r--sys/powerpc/aim/mmu_oea.c104
3 files changed, 60 insertions, 70 deletions
diff --git a/sys/powerpc/aim/locore.S b/sys/powerpc/aim/locore.S
index ab6aade..62dd006 100644
--- a/sys/powerpc/aim/locore.S
+++ b/sys/powerpc/aim/locore.S
@@ -182,6 +182,9 @@ __start:
mr 7,21
bl powerpc_init
+ mr %r1, %r3
+ li %r3, 0
+ stw %r3, 0(%r1)
bl mi_startup
b OF_exit
diff --git a/sys/powerpc/aim/machdep.c b/sys/powerpc/aim/machdep.c
index ceeadee..f28d5c2 100644
--- a/sys/powerpc/aim/machdep.c
+++ b/sys/powerpc/aim/machdep.c
@@ -132,9 +132,6 @@ int cold = 1;
static struct pcpu pcpu0;
static struct trapframe frame0;
-vm_offset_t kstack0;
-vm_offset_t kstack0_phys;
-
char machine[] = "powerpc";
SYSCTL_STRING(_hw, HW_MACHINE, machine, CTLFLAG_RD, machine, 0, "");
@@ -145,7 +142,7 @@ SYSCTL_INT(_machdep, CPU_CACHELINE, cacheline_size,
static void cpu_startup(void *);
SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL);
-void powerpc_init(u_int, u_int, u_int, void *);
+u_int powerpc_init(u_int, u_int, u_int, void *);
int save_ofw_mapping(void);
int restore_ofw_mapping(void);
@@ -248,11 +245,11 @@ extern void *extint, *extsize;
extern void *dblow, *dbsize;
extern void *vectrap, *vectrapsize;
-void
+u_int
powerpc_init(u_int startkernel, u_int endkernel, u_int basekernel, void *mdp)
{
struct pcpu *pc;
- vm_offset_t end, off;
+ vm_offset_t end;
void *kmdp;
char *env;
@@ -295,7 +292,6 @@ powerpc_init(u_int startkernel, u_int endkernel, u_int basekernel, void *mdp)
pc = &pcpu0;
pcpu_init(pc, 0, sizeof(struct pcpu));
pc->pc_curthread = &thread0;
- pc->pc_curpcb = thread0.td_pcb;
pc->pc_cpuid = 0;
__asm __volatile("mtsprg 0, %0" :: "r"(pc));
@@ -379,15 +375,12 @@ powerpc_init(u_int startkernel, u_int endkernel, u_int basekernel, void *mdp)
/*
* Finish setting up thread0.
*/
- thread0.td_kstack = kstack0;
thread0.td_pcb = (struct pcb *)
- (thread0.td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1;
+ ((thread0.td_kstack + thread0.td_kstack_pages * PAGE_SIZE -
+ sizeof(struct pcb)) & ~15);
+ pc->pc_curpcb = thread0.td_pcb;
- /*
- * Map and initialise the message buffer.
- */
- for (off = 0; off < round_page(MSGBUF_SIZE); off += PAGE_SIZE)
- pmap_kenter((vm_offset_t)msgbufp + off, msgbuf_phys + off);
+ /* Initialise the message buffer. */
msgbufinit(msgbufp, MSGBUF_SIZE);
#ifdef KDB
@@ -395,6 +388,8 @@ powerpc_init(u_int startkernel, u_int endkernel, u_int basekernel, void *mdp)
kdb_enter(KDB_WHY_BOOTFLAGS,
"Boot flags requested debugger");
#endif
+
+ return (((uintptr_t)thread0.td_pcb - 16) & ~15);
}
void
diff --git a/sys/powerpc/aim/mmu_oea.c b/sys/powerpc/aim/mmu_oea.c
index db2c3bb..ac8bcb8 100644
--- a/sys/powerpc/aim/mmu_oea.c
+++ b/sys/powerpc/aim/mmu_oea.c
@@ -266,8 +266,8 @@ SYSCTL_INT(_machdep, OID_AUTO, moea_pte_spills, CTLFLAG_RD,
struct pvo_entry *moea_pvo_zeropage;
struct mtx moea_pvo_zeropage_mtx;
-vm_offset_t moea_rkva_start = VM_MIN_KERNEL_ADDRESS;
-u_int moea_rkva_count = 4;
+vm_offset_t moea_rkva_start;
+u_int moea_rkva_count;
/*
* Allocate physical memory for use in moea_bootstrap.
@@ -664,27 +664,11 @@ moea_bootstrap(mmu_t mmup, vm_offset_t kernelstart, vm_offset_t kernelend)
"mtdbatu 0,%0; mtdbatl 0,%1; isync"
:: "r"(batu), "r"(batl));
-#if 0
- /* map frame buffer */
- batu = BATU(0x90000000, BAT_BL_256M, BAT_Vs);
- batl = BATL(0x90000000, BAT_I|BAT_G, BAT_PP_RW);
- __asm ("mtdbatu 1,%0; mtdbatl 1,%1; isync"
- :: "r"(batu), "r"(batl));
-#endif
-
-#if 1
/* map pci space */
batu = BATU(0x80000000, BAT_BL_256M, BAT_Vs);
batl = BATL(0x80000000, BAT_I|BAT_G, BAT_PP_RW);
__asm ("mtdbatu 1,%0; mtdbatl 1,%1; isync"
:: "r"(batu), "r"(batl));
-#endif
-
- /*
- * Set the start and end of kva.
- */
- virtual_avail = VM_MIN_KERNEL_ADDRESS;
- virtual_end = VM_MAX_KERNEL_ADDRESS;
mem_regions(&pregions, &pregions_sz, &regions, &regions_sz);
CTR0(KTR_PMAP, "moea_bootstrap: physical memory");
@@ -785,11 +769,6 @@ moea_bootstrap(mmu_t mmup, vm_offset_t kernelstart, vm_offset_t kernelend)
MTX_RECURSE);
/*
- * Allocate the message buffer.
- */
- msgbuf_phys = moea_bootstrap_alloc(MSGBUF_SIZE, 0);
-
- /*
* Initialise the unmanaged pvo pool.
*/
moea_bpvo_pool = (struct pvo_entry *)moea_bootstrap_alloc(
@@ -856,9 +835,13 @@ moea_bootstrap(mmu_t mmup, vm_offset_t kernelstart, vm_offset_t kernelend)
ofw_mappings++;
}
}
-#ifdef SMP
- TLBSYNC();
-#endif
+
+ /*
+ * Calculate the last available physical address.
+ */
+ for (i = 0; phys_avail[i + 2] != 0; i += 2)
+ ;
+ Maxmem = powerpc_btop(phys_avail[i + 1]);
/*
* Initialize the kernel pmap (which is statically allocated).
@@ -872,36 +855,6 @@ moea_bootstrap(mmu_t mmup, vm_offset_t kernelstart, vm_offset_t kernelend)
kernel_pmap->pm_active = ~0;
/*
- * Allocate a kernel stack with a guard page for thread0 and map it
- * into the kernel page map.
- */
- pa = moea_bootstrap_alloc(KSTACK_PAGES * PAGE_SIZE, 0);
- kstack0_phys = pa;
- kstack0 = virtual_avail + (KSTACK_GUARD_PAGES * PAGE_SIZE);
- CTR2(KTR_PMAP, "moea_bootstrap: kstack0 at %#x (%#x)", kstack0_phys,
- kstack0);
- virtual_avail += (KSTACK_PAGES + KSTACK_GUARD_PAGES) * PAGE_SIZE;
- for (i = 0; i < KSTACK_PAGES; i++) {
- pa = kstack0_phys + i * PAGE_SIZE;
- va = kstack0 + i * PAGE_SIZE;
- moea_kenter(mmup, va, pa);
- TLBIE(va);
- }
-
- /*
- * Calculate the last available physical address.
- */
- for (i = 0; phys_avail[i + 2] != 0; i += 2)
- ;
- Maxmem = powerpc_btop(phys_avail[i + 1]);
-
- /*
- * Allocate virtual address space for the message buffer.
- */
- msgbufp = (struct msgbuf *)virtual_avail;
- virtual_avail += round_page(MSGBUF_SIZE);
-
- /*
* Initialize hardware.
*/
for (i = 0; i < 16; i++) {
@@ -916,6 +869,45 @@ moea_bootstrap(mmu_t mmup, vm_offset_t kernelstart, vm_offset_t kernelend)
tlbia();
pmap_bootstrapped++;
+
+ /*
+ * Set the start and end of kva.
+ */
+ virtual_avail = VM_MIN_KERNEL_ADDRESS;
+ virtual_end = VM_MAX_KERNEL_ADDRESS;
+
+ moea_rkva_start = virtual_avail;
+ moea_rkva_count = 4;
+ virtual_avail += moea_rkva_count * PAGE_SIZE;
+
+ /*
+ * Allocate a kernel stack with a guard page for thread0 and map it
+ * into the kernel page map.
+ */
+ pa = moea_bootstrap_alloc(KSTACK_PAGES * PAGE_SIZE, PAGE_SIZE);
+ va = virtual_avail + KSTACK_GUARD_PAGES * PAGE_SIZE;
+ virtual_avail = va + KSTACK_PAGES * PAGE_SIZE;
+ CTR2(KTR_PMAP, "moea_bootstrap: kstack0 at %#x (%#x)", pa, va);
+ thread0.td_kstack = va;
+ thread0.td_kstack_pages = KSTACK_PAGES;
+ for (i = 0; i < KSTACK_PAGES; i++) {
+ moea_kenter(mmup, va, pa);;
+ pa += PAGE_SIZE;
+ va += PAGE_SIZE;
+ }
+
+ /*
+ * Allocate virtual address space for the message buffer.
+ */
+ pa = msgbuf_phys = moea_bootstrap_alloc(MSGBUF_SIZE, PAGE_SIZE);
+ msgbufp = (struct msgbuf *)virtual_avail;
+ va = virtual_avail;
+ virtual_avail += round_page(MSGBUF_SIZE);
+ while (va < virtual_avail) {
+ moea_kenter(mmup, va, pa);;
+ pa += PAGE_SIZE;
+ va += PAGE_SIZE;
+ }
}
/*
OpenPOWER on IntegriCloud