From: John Hodge Date: Thu, 13 Oct 2011 13:42:43 +0000 (+0800) Subject: Kernel/armv7 - Implementing MM_Clone and fixing MMU errors X-Git-Tag: rel0.13~75 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=d3f9be02956fb2633d2322ffad4198e03117d353;p=tpg%2Facess2.git Kernel/armv7 - Implementing MM_Clone and fixing MMU errors --- diff --git a/Kernel/arch/armv7/include/mm_virt.h b/Kernel/arch/armv7/include/mm_virt.h index ef3de83f..1228998f 100644 --- a/Kernel/arch/armv7/include/mm_virt.h +++ b/Kernel/arch/armv7/include/mm_virt.h @@ -5,7 +5,7 @@ #ifndef _MM_VIRT_H_ #define _MM_VIRT_H_ -#define MM_KSTACK_SIZE 0x10000 +#include "options.h" #define MM_USER_MIN 0x00001000 #define USER_LIB_MAX 0x70000000 @@ -13,7 +13,7 @@ #define MM_KSTACK_END 0x7F000000 #define MM_PPD_HANDLES 0x7F800000 #define MM_TABLE1USER 0x7FC00000 // 2 GiB - 4 MiB -#define MM_TABLE0USER 0x7FEFE000 // 2 GiB - 2 MiB - 2 pages +#define MM_TABLE0USER 0x7FDFC000 // 2 GiB - 2 MiB - 4 pages // Page Blocks are 12-bits wide (12 address bits used) // Hence, the table is 16KiB large (and must be so aligned) diff --git a/Kernel/arch/armv7/include/options.h b/Kernel/arch/armv7/include/options.h new file mode 100644 index 00000000..0fbec5f9 --- /dev/null +++ b/Kernel/arch/armv7/include/options.h @@ -0,0 +1,19 @@ +/* + * Acess2 ARMv7 Port + * - By John Hodge (thePowersGang) + * + * options.h + * - C/ASM Shared constants + */ +#ifndef _ARMV7_OPTIONS_H_ +#define _ARMV7_OPTIONS_H_ + +#define KERNEL_BASE 0x80000000 + +//#define PCI_PADDR 0x60000000 // Realview (Non-PB) +#define UART0_PADDR 0x10009000 // Realview + +#define MM_KSTACK_SIZE 0x2000 // 2 Pages + +#endif + diff --git a/Kernel/arch/armv7/link.ld b/Kernel/arch/armv7/link.ld index 329bc9bd..b1ae2957 100644 --- a/Kernel/arch/armv7/link.ld +++ b/Kernel/arch/armv7/link.ld @@ -15,6 +15,7 @@ SECTIONS *(.text*) *(.rodata*) } + /* 0x4000 (4 pages) alignment needed for root table */ .data ALIGN(0x4000) : AT( ADDR(.data) - _kernel_base ) { *(.padata) @@ -32,6 +33,8 @@ SECTIONS { *(.bss*) *(COMMON*) + . = ALIGN(0x1000); + *(.pabss) } gKernelEnd = .; } diff --git a/Kernel/arch/armv7/mm_virt.c b/Kernel/arch/armv7/mm_virt.c index b6d022df..a023c423 100644 --- a/Kernel/arch/armv7/mm_virt.c +++ b/Kernel/arch/armv7/mm_virt.c @@ -13,6 +13,7 @@ #define AP_KRO_ONLY 0x5 #define AP_RW_BOTH 0x3 #define AP_RO_BOTH 0x6 +#define PADDR_MASK_LVL1 0xFFFFFC00 // === IMPORTS === extern Uint32 kernel_table0[]; @@ -31,6 +32,7 @@ typedef struct //#define FRACTAL(table1, addr) ((table1)[ (0xFF8/4*1024) + ((addr)>>20)]) #define FRACTAL(table1, addr) ((table1)[ (0xFF8/4*1024) + ((addr)>>22)]) +#define USRFRACTAL(table1, addr) ((table1)[ (0x7F8/4*1024) + ((addr)>>22)]) #define TLBIALL() __asm__ __volatile__ ("mcr p15, 0, %0, c8, c7, 0" : : "r" (0)) // === PROTOTYPES === @@ -38,7 +40,12 @@ void MM_int_GetTables(tVAddr VAddr, Uint32 **Table0, Uint32 **Table1); int MM_int_AllocateCoarse(tVAddr VAddr, int Domain); int MM_int_SetPageInfo(tVAddr VAddr, tMM_PageInfo *pi); int MM_int_GetPageInfo(tVAddr VAddr, tMM_PageInfo *pi); +tPAddr MM_AllocateRootTable(void); +void MM_int_CloneTable(Uint32 *DestEnt, int Table); +tPAddr MM_Clone(void); tVAddr MM_NewKStack(int bGlobal); +void MM_int_DumpTableEnt(tVAddr Start, size_t Len, tMM_PageInfo *Info); +//void MM_DumpTables(tVAddr Start, tVAddr End); // === GLOBALS === @@ -199,6 +206,8 @@ int MM_int_GetPageInfo(tVAddr VAddr, tMM_PageInfo *pi) { Uint32 *table0, *table1; Uint32 desc; + +// LogF("MM_int_GetPageInfo: VAddr=%p, pi=%p\n", VAddr, pi); MM_int_GetTables(VAddr, &table0, &table1); @@ -210,7 +219,7 @@ int MM_int_GetPageInfo(tVAddr VAddr, tMM_PageInfo *pi) pi->bExecutable = 1; pi->bGlobal = 0; pi->bShared = 0; - + pi->AP = 0; switch( (desc & 3) ) { @@ -238,15 +247,21 @@ int MM_int_GetPageInfo(tVAddr VAddr, tMM_PageInfo *pi) case 1: pi->Size = 16; pi->PhysAddr = desc & 0xFFFF0000; + pi->AP = ((desc >> 4) & 3) | (((desc >> 9) & 1) << 2); + pi->bExecutable = !(desc & 0x8000); + pi->bShared = (desc >> 10) & 1; +// LogF("Large page, VAddr = %p, table1[VAddr>>12] = %p, desc = %x\n", VAddr, &table1[ VAddr >> 12 ], desc); +// LogF("Par desc = %p %x\n", &table0[ VAddr >> 20 ], table0[ VAddr >> 20 ]); return 0; // 2/3: Small page case 2: case 3: pi->Size = 12; pi->PhysAddr = desc & 0xFFFFF000; - pi->bExecutable = desc & 1; + pi->bExecutable = !(desc & 1); pi->bGlobal = !(desc >> 11); pi->bShared = (desc >> 10) & 1; + pi->AP = ((desc >> 4) & 3) | (((desc >> 9) & 1) << 2); return 0; } return 1; @@ -259,7 +274,8 @@ int MM_int_GetPageInfo(tVAddr VAddr, tMM_PageInfo *pi) pi->PhysAddr |= (Uint64)((desc >> 20) & 0xF) << 32; pi->PhysAddr |= (Uint64)((desc >> 5) & 0x7) << 36; pi->Size = 24; - pi->Domain = 0; // Superpages default to zero + pi->Domain = 0; // Supersections default to zero + pi->AP = ((desc >> 10) & 3) | (((desc >> 15) & 1) << 2); return 0; } @@ -267,6 +283,7 @@ int MM_int_GetPageInfo(tVAddr VAddr, tMM_PageInfo *pi) pi->PhysAddr = desc & 0xFFF80000; pi->Size = 20; pi->Domain = (desc >> 5) & 7; + pi->AP = ((desc >> 10) & 3) | (((desc >> 15) & 1) << 2); return 0; // 3: Reserved (invalid) @@ -373,6 +390,155 @@ void MM_Deallocate(tVAddr VAddr) MM_int_SetPageInfo(VAddr, &pi); } +tPAddr MM_AllocateRootTable(void) +{ + tPAddr ret; + + ret = MM_AllocPhysRange(2, -1); + if( ret & 0x1000 ) { + MM_DerefPhys(ret); + MM_DerefPhys(ret+0x1000); + ret = MM_AllocPhysRange(3, -1); + if( ret & 0x1000 ) { + MM_DerefPhys(ret); + ret += 0x1000; + } + else { + MM_DerefPhys(ret + 0x2000); + } + } + return ret; +} + +void MM_int_CloneTable(Uint32 *DestEnt, int Table) +{ + tPAddr table; + Uint32 *tmp_map; + Uint32 *cur = (void*)MM_TABLE0USER; +// Uint32 *cur = &FRACTAL(MM_TABLE1USER,0); + int i; + + table = MM_AllocPhys(); + if(!table) return ; + + tmp_map = (void*)MM_MapTemp(table); + + for( i = 0; i < 1024; i ++ ) + { + switch(cur[i] & 3) + { + case 0: tmp_map[i] = 0; break; + case 1: + tmp_map[i] = 0; + Log_Error("MMVirt", "TODO: Support large pages in MM_int_CloneTable"); + // Large page? + break; + case 2: + case 3: + // Small page + // - If full RW + if( (cur[Table*256] & 0x230) == 0x030 ) + cur[Table*256+i] |= 0x200; // Set to full RO (Full RO=COW, User RO = RO) + tmp_map[i] = cur[Table*256+i]; + break; + } + } + + DestEnt[0] = table + 0*0x400 + 1; + DestEnt[1] = table + 1*0x400 + 1; + DestEnt[2] = table + 2*0x400 + 1; + DestEnt[3] = table + 3*0x400 + 1; +} + +tPAddr MM_Clone(void) +{ + tPAddr ret; + Uint32 *new_lvl1_1, *new_lvl1_2, *cur; + Uint32 *tmp_map; + int i; + + ret = MM_AllocateRootTable(); + + cur = (void*)MM_TABLE0USER; + new_lvl1_1 = (void*)MM_MapTemp(ret); + new_lvl1_2 = (void*)MM_MapTemp(ret+0x1000); + tmp_map = new_lvl1_1; + new_lvl1_1[0] = 0x8202; // Section mapping the first meg for exception vectors (K-RO) + for( i = 1; i < 0x800-4; i ++ ) + { +// Log("i = %i", i); + if( i == 0x400 ) { + tmp_map = &new_lvl1_2[-0x400]; + Log("tmp_map = %p", tmp_map); + } + switch( cur[i] & 3 ) + { + case 0: tmp_map[i] = 0; break; + case 1: + MM_int_CloneTable(&tmp_map[i], i); + i += 3; // Tables are alocated in blocks of 4 + break; + case 2: + case 3: + Log_Error("MMVirt", "TODO: Support Sections/Supersections in MM_Clone (i=%i)", i); + tmp_map[i] = 0; + break; + } + } + + // Allocate Fractal table + { + int j, num; + tPAddr tmp = MM_AllocPhys(); + Uint32 *table = (void*)MM_MapTemp(tmp); + Uint32 sp; + register Uint32 __SP asm("sp"); + // Map table to last 4MiB of user space + tmp_map[i+0] = tmp + 0*0x400 + 1; + tmp_map[i+1] = tmp + 1*0x400 + 1; + tmp_map[i+2] = tmp + 2*0x400 + 1; + tmp_map[i+3] = tmp + 3*0x400 + 1; + for( j = 0; j < 256; j ++ ) { + table[j] = new_lvl1_1[j*4] & PADDR_MASK_LVL1;// 0xFFFFFC00; + table[j] |= 0x10|3; // Kernel Only, Small table, XN + } + for( ; j < 512; j ++ ) { + table[j] = new_lvl1_2[(j-256)*4] & PADDR_MASK_LVL1;// 0xFFFFFC00; + table[j] |= 0x10|3; // Kernel Only, Small table, XN + } + for( ; j < 1024; j ++ ) + table[j] = 0; + + // Get kernel stack bottom + sp = __SP; + sp &= ~(MM_KSTACK_SIZE-1); + j = (sp / 0x1000) % 1024; + num = MM_KSTACK_SIZE/0x1000; + Log("sp = %p, j = %i", sp, j); + + // Copy stack pages + for(; num--; j ++, sp += 0x1000) + { + tVAddr page = MM_AllocPhys(); + void *tmp_page; + table[j] = page | 0x13; + tmp_page = (void*)MM_MapTemp(page); + memcpy(tmp_page, (void*)sp, 0x1000); + MM_FreeTemp( (tVAddr)tmp_page ); + } + + MM_FreeTemp( (tVAddr)table ); + } + + tmp_map = &tmp_map[0x400]; + MM_FreeTemp( (tVAddr)tmp_map ); + + Log("Table dump"); + MM_DumpTables(0, -1); + + return ret; +} + tPAddr MM_ClearUser(void) { // TODO: Implement ClearUser @@ -414,9 +580,12 @@ tVAddr MM_MapHWPages(tPAddr PAddr, Uint NPages) int i; tMM_PageInfo pi; + ENTER("xPAddr iNPages", PAddr, NPages); + // Scan for a location for( ret = MM_HWMAP_BASE; ret < MM_HWMAP_END - NPages * PAGE_SIZE; ret += PAGE_SIZE ) { +// LOG("checking %p", ret); // Check if there is `NPages` free pages for( i = 0; i < NPages; i ++ ) { @@ -424,6 +593,7 @@ tVAddr MM_MapHWPages(tPAddr PAddr, Uint NPages) break; } // Nope, jump to after the used page found and try again +// LOG("i = %i, ==? %i", i, NPages); if( i != NPages ) { ret += i * PAGE_SIZE; continue ; @@ -433,9 +603,11 @@ tVAddr MM_MapHWPages(tPAddr PAddr, Uint NPages) for( i = 0; i < NPages; i ++ ) MM_Map(ret+i*PAGE_SIZE, PAddr+i*PAddr); // and return + LEAVE('p', ret); return ret; } Log_Warning("MMVirt", "MM_MapHWPages: No space for a %i page block", NPages); + LEAVE('p', 0); return 0; } @@ -493,8 +665,46 @@ tVAddr MM_NewKStack(int bShared) return addr + ofs; } +void MM_int_DumpTableEnt(tVAddr Start, size_t Len, tMM_PageInfo *Info) +{ + Log("%p => %8x - 0x%7x %i %x", + Start, Info->PhysAddr-Len, Len, + Info->Domain, + Info->AP + ); +} + void MM_DumpTables(tVAddr Start, tVAddr End) { + tVAddr range_start = 0, addr; + tMM_PageInfo pi, pi_old; + int i = 0, inRange=0; + pi_old.Size = 0; + + range_start = Start; + for( addr = Start; i == 0 || (addr && addr < End); i = 1 ) + { + int rv = MM_int_GetPageInfo(addr, &pi); + if( rv + || pi.Size != pi_old.Size + || pi.Domain != pi_old.Domain + || pi.AP != pi_old.AP + || pi_old.PhysAddr != pi.PhysAddr ) + { + if(inRange) { + MM_int_DumpTableEnt(range_start, addr - range_start, &pi_old); + } + addr &= ~((1 << pi.Size)-1); + range_start = addr; + } + + pi_old = pi; + pi_old.PhysAddr += 1 << pi_old.Size; + addr += 1 << pi_old.Size; + inRange = (rv == 0); + } + if(inRange) + MM_int_DumpTableEnt(range_start, addr - range_start, &pi); } diff --git a/Kernel/arch/armv7/proc.S b/Kernel/arch/armv7/proc.S index 832adbd1..e9273146 100644 --- a/Kernel/arch/armv7/proc.S +++ b/Kernel/arch/armv7/proc.S @@ -42,7 +42,7 @@ KernelThreadHeader: @ R3: Pointer to save old IP @ SP+0: New address space SwitchTask: - PUSH_GPRS + push {r4-r12,lr} @ Save IP ldr r4, =.return @@ -61,6 +61,26 @@ SwitchTask: bx r2 .return: - POP_GPRS - bx lr + push {r4-r12,pc} +.extern MM_Clone +.extern MM_DumpTables +.globl Proc_CloneInt +Proc_CloneInt: + @ R0: SP Destination + @ R1: Mem Destination + push {r4-r12,lr} + mov r4, r1 @ Save mem destination + str sp, [r0] @ Save SP to SP dest + + bl MM_Clone + str r0, [r4] @ Save clone return to Mem Dest + + ldr r0, =Proc_CloneInt_new + pop {r4-r12,pc} +Proc_CloneInt_new: + mov r0, #0 + mov r1, #0x80000000 + bl MM_DumpTables + mov r0, #0 + pop {r4-r12,pc} diff --git a/Kernel/arch/armv7/proc.c b/Kernel/arch/armv7/proc.c index 146899c1..c336fc3f 100644 --- a/Kernel/arch/armv7/proc.c +++ b/Kernel/arch/armv7/proc.c @@ -13,7 +13,7 @@ extern tThread gThreadZero; extern void SwitchTask(Uint32 NewSP, Uint32 *OldSP, Uint32 NewIP, Uint32 *OldIP, Uint32 MemPtr); extern void KernelThreadHeader(void); // Actually takes args on stack -extern void Proc_CloneInt(Uint32 *SP, Uint32 *MemPtr); +extern Uint32 Proc_CloneInt(Uint32 *SP, Uint32 *MemPtr); extern tVAddr MM_NewKStack(int bGlobal); // TODO: Move out into a header // === PROTOTYPES === @@ -32,7 +32,6 @@ void ArchThreads_Init(void) void Proc_IdleThread(void *unused) { Threads_SetPriority(gpIdleThread, -1); - Threads_SetName("Idle Thread"); for(;;) { Proc_Reschedule(); __asm__ __volatile__ ("wfi"); @@ -45,6 +44,7 @@ void Proc_Start(void) tid = Proc_NewKThread( Proc_IdleThread, NULL ); gpIdleThread = Threads_GetThread(tid); + gpIdleThread->ThreadName = (char*)"Idle Thread"; } int GetCPUNum(void) @@ -66,13 +66,25 @@ void Proc_StartUser(Uint Entrypoint, Uint *Bases, int ArgC, char **ArgV, char ** tTID Proc_Clone(Uint Flags) { tThread *new; + Uint32 pc, sp, mem; new = Threads_CloneTCB(Flags); if(!new) return -1; + + // Actual clone magic + pc = Proc_CloneInt(&sp, &mem); + if(pc == 0) { + Log("Proc_Clone: In child"); + return 0; + } - Log_Error("Proc", "TODO: Implement Proc_Clone"); - - return -1; + new->SavedState.IP = pc; + new->SavedState.SP = sp; + new->MemState.Base = mem; + + Threads_AddActive(new); + + return new->TID; } tTID Proc_SpawnWorker( void (*Fnc)(void*), void *Ptr ) @@ -82,6 +94,8 @@ tTID Proc_SpawnWorker( void (*Fnc)(void*), void *Ptr ) new = Threads_CloneThreadZero(); if(!new) return -1; + free(new->ThreadName); + new->ThreadName = NULL; new->KernelStack = MM_NewKStack(1); if(!new->KernelStack) { @@ -112,6 +126,8 @@ tTID Proc_NewKThread( void (*Fnc)(void*), void *Ptr ) new = Threads_CloneTCB(0); if(!new) return -1; + free(new->ThreadName); + new->ThreadName = NULL; // TODO: Non-shared stack new->KernelStack = MM_NewKStack(1); @@ -151,11 +167,11 @@ void Proc_Reschedule(void) if(!next) next = gpIdleThread; if(!next || next == cur) return; - Log("Switching to %p (%i %s) IP=%p SP=%p", next, next->TID, next->ThreadName, next->SavedState.IP, next->SavedState.SP); + Log("Switching to %p (%i %s)", next, next->TID, next->ThreadName); + Log(" IP=%p SP=%p TTBR0=%p", next->SavedState.IP, next->SavedState.SP, next->MemState.Base); Log("Requested by %p", __builtin_return_address(0)); gpCurrentThread = next; - // TODO: Change kernel stack? SwitchTask( next->SavedState.SP, &cur->SavedState.SP, diff --git a/Kernel/arch/armv7/start.S b/Kernel/arch/armv7/start.S index 078b9986..faf10ea9 100644 --- a/Kernel/arch/armv7/start.S +++ b/Kernel/arch/armv7/start.S @@ -1,9 +1,7 @@ #include "include/assembly.h" +#include "include/options.h" -KERNEL_BASE = 0x80000000 -PCI_PADDR = 0x60000000 @ Realview -UART0_PADDR = 0x10009000 @ Realview @ @ Exception defs taken from ARM DDI 0406B @ @@ -12,7 +10,7 @@ interrupt_vector_table: ivt_reset: b _start @ Reset ivt_undef: b . @ #UD ivt_svc: b SyscallHandler @ SVC (SWI assume) -ivt_prefetch: b DataAbort @ Prefetch abort +ivt_prefetch: b PrefetchAbort @ Prefetch abort ivt_data: b DataAbort @ Data abort ivt_unused: b . @ Not Used ivt_irq: b IRQHandler @ IRQ @@ -40,14 +38,14 @@ _start: ldr sp, =irqstack+0x1000 @ Set up stack cps #19 - ldr sp, =stack+0x10000 @ Set up stack +@ ldr sp, =stack+0x10000 @ Set up stack + ldr sp, =0x80000000-4 @ Set up stack (top of user range) ldr r0, =kmain mov pc, r0 1: b 1b @ Infinite loop _ptr_kmain: .long kmain -.comm stack, 0x10000 @ ; 64KiB Stack .comm irqstack, 0x1000 @ ; 4KiB Stack SyscallHandler: @@ -85,11 +83,14 @@ DataAbort: sub lr, #8 @ Adjust LR to the correct value srsdb sp!, #19 @ Switch to supervisor mode (DDI0406B D1.6.5) (actually SRSFD) cpsid ifa, #19 - PUSH_GPRS +@ PUSH_GPRS + mrc p15, 0, r4, c5, c0, 0 @ Read DFSR (Data Fault Address Register) to stack + push {r4} + mrc p15, 0, r3, c6, c0, 0 @ Read DFAR (Data Fault Address Register) into R3 mov r2, lr ldr r1, =csDataAbort_Fmt - ldr r0, =csDataAbort_Tag + ldr r0, =csAbort_Tag ldr r4, =Log_Error blx r4 b . @@ -98,15 +99,30 @@ DataAbort: rfeia sp! @ Pop state (actually RFEFD) bx lr +.globl PrefetchAbort +PrefetchAbort: + sub lr, #4 @ Adjust LR to the correct value + srsdb sp!, #19 @ Switch to supervisor mode (DDI0406B D1.6.5) (actually SRSFD) + cpsid ifa, #19 + PUSH_GPRS + + ldr r0, =csAbort_Tag + ldr r1, =csPrefetchAbort_Fmt + mov r2, lr + mrc p15, 0, r3, c5, c0, 0 @ Read IFSR (Instruction Fault Address Register) into R3 + ldr r4, =Log_Error + blx r4 + b . + csIRQ_Tag: -csDataAbort_Tag: +csAbort_Tag: .asciz "ARMv7" csIRQ_Fmt: .asciz "IRQ" csDataAbort_Fmt: - .asciz "Data Abort at %p" - -.comm irqstack, 0x1000 + .asciz "Data Abort - %p accessed %p, DFSR=%x Unk:%x Unk:%x" +csPrefetchAbort_Fmt: + .asciz "Prefetch Abort at %p, IFSR=%x" .section .padata .globl kernel_table0 @@ -116,10 +132,10 @@ kernel_table0: .rept 0x7FC - 1 .long 0 .endr - .long user_table1_map + 0x000 - KERNEL_BASE + 1 - .long user_table1_map + 0x400 - KERNEL_BASE + 1 - .long 0 @ user_table1_map + 0x800 - KERNEL_BASE + 1 - .long 0 @ user_table1_map + 0xC00 - KERNEL_BASE + 1 + .long user_table1_map + 0x000 - KERNEL_BASE + 1 @ 0x7FC00000 + .long user_table1_map + 0x400 - KERNEL_BASE + 1 @ 0x7FD00000 + .long user_table1_map + 0x800 - KERNEL_BASE + 1 @ KStacks + .long user_table1_map + 0xC00 - KERNEL_BASE + 1 @ 0x80000000 - User/Kernel split .long 0x00000002 @ Map first 4 MiB to 2GiB .long 0x00100002 @ @@ -162,31 +178,39 @@ kernel_table0: .long kernel_table1_map + 0x400 - KERNEL_BASE + 1 .long kernel_table1_map + 0x800 - KERNEL_BASE + 1 .long kernel_table1_map + 0xC00 - KERNEL_BASE + 1 - @ Top level fractals - .long 0 @ removed for alignment constraints, using the KERNEL_BASE identity mapping instead - .rept 0x1000 - 0xFF8 - 5 + .rept 0x1000 - 0xFFC .long 0 .endr @ PID0 user table .globl user_table1_map -user_table1_map: @ Size = 4KiB - .rept 0x7F8/4 +@ User table1 data table (only the first half is needed) +@ - Abused to provide kernel stacks in upper half +user_table1_map: @ Size = 4KiB (only 2KiB used) + .rept 0x800/4-4 .long 0 .endr - .long kernel_table0 - KERNEL_BASE + (1 << 4) + 3 - .long user_table1_map - KERNEL_BASE + (1 << 4) + 3 - .rept 0x800/4 + .long kernel_table0 + 0x0000 - KERNEL_BASE + 0x10 + 3 @ ...1FC000 = 0x7FDDC000 + .long kernel_table0 + 0x1000 - KERNEL_BASE + 0x10 + 3 @ ...1FD000 = 0x7FDDD000 + .long 0 + .long user_table1_map - KERNEL_BASE + 0x10 + 3 @ ...1FF000 = 0x7FDFF000 + @ Kernel stack zone + .rept (0x800/4)-(MM_KSTACK_SIZE/0x1000) .long 0 .endr + #if MM_KSTACK_SIZE != 0x2000 + #error Kernel stack size not changed in start.S + #endif + .long stack + 0x0000 - KERNEL_BASE + 0x10 + 3 @ Kernel Stack + .long stack + 0x1000 - KERNEL_BASE + 0x10 + 3 @ .globl kernel_table1_map kernel_table1_map: @ Size = 4KiB - .rept 0xF00/4 + .rept (0xF00+16)/4 .long 0 .endr .long hwmap_table_0 - KERNEL_BASE + (1 << 4) + 3 - .rept 0xFF8/4 - 0xF00/4 - 1 + .rept 0xFF8/4 - (0xF00+16)/4 - 1 .long 0 .endr .long kernel_table1_map - KERNEL_BASE + (1 << 4) + 3 @@ -200,3 +224,7 @@ hwmap_table_0: .long 0 .endr +.section .padata +stack: + .space MM_KSTACK_SIZE, 0 @ Original kernel stack +