diff --git a/src/system/boot/platform/bios_ia32/mmu.cpp b/src/system/boot/platform/bios_ia32/mmu.cpp index a70b4cb6c6..ebba1e277d 100644 --- a/src/system/boot/platform/bios_ia32/mmu.cpp +++ b/src/system/boot/platform/bios_ia32/mmu.cpp @@ -59,6 +59,23 @@ struct extended_memory { uint32 type; }; +#ifdef _PXE_ENV + +static const uint32 kDefaultPageTableFlags = 0x07; // present, user, R/W +static const size_t kMaxKernelSize = 0x100000; // 1 MB for the kernel +static const uint32 kPageTableRegionEnd = 0x110000; + +// working page directory and page table +static uint32 *sPageDirectory = 0; + +static addr_t sNextPhysicalAddress = 0x110000; +static addr_t sNextVirtualAddress = KERNEL_BASE + kMaxKernelSize; +static addr_t sMaxVirtualAddress = KERNEL_BASE + 0x400000; + +static addr_t sNextPageTableAddress = 0x100000; + +#else + static const uint32 kDefaultPageTableFlags = 0x07; // present, user, R/W static const size_t kMaxKernelSize = 0x100000; // 1 MB for the kernel static const uint32 kPageTableRegionEnd = 0x9e000; @@ -73,6 +90,8 @@ static addr_t sMaxVirtualAddress = KERNEL_BASE + 0x400000; static addr_t sNextPageTableAddress = 0x90000; +#endif + static addr_t get_next_virtual_address(size_t size) @@ -266,7 +285,7 @@ init_page_directory(void) // These page tables won't be taken over into the kernel. // make the first page table at the first free spot - uint32 *pageTable = get_next_page_table();; + uint32 *pageTable = get_next_page_table(); for (int32 i = 0; i < 1024; i++) { pageTable[i] = (i * 0x1000) | kDefaultPageFlags; @@ -275,7 +294,7 @@ init_page_directory(void) sPageDirectory[0] = (uint32)pageTable | kDefaultPageFlags; // make the second page table - pageTable = get_next_page_table();; + pageTable = get_next_page_table(); for (int32 i = 0; i < 1024; i++) { pageTable[i] = (i * 0x1000 + 0x400000) | kDefaultPageFlags; diff --git a/src/system/boot/platform/bios_ia32/smp.cpp b/src/system/boot/platform/bios_ia32/smp.cpp index 65834c3911..13d534d0ba 100644 --- a/src/system/boot/platform/bios_ia32/smp.cpp +++ b/src/system/boot/platform/bios_ia32/smp.cpp @@ -396,8 +396,13 @@ smp_boot_other_cpus(void) // allocate a stack and a code area for the smp trampoline // (these have to be < 1M physical, 0xa0000-0xfffff is reserved by the BIOS) +#ifdef _PXE_ENV + trampolineCode = 0x8b000; + trampolineStack = 0x8c000; +#else trampolineCode = 0x9f000; trampolineStack = 0x9e000; +#endif // copy the trampoline code over memcpy((char *)trampolineCode, (const void*)&smp_trampoline, diff --git a/src/system/boot/platform/pxe_ia32/Jamfile b/src/system/boot/platform/pxe_ia32/Jamfile index 21cdbf53b8..91024aee51 100644 --- a/src/system/boot/platform/pxe_ia32/Jamfile +++ b/src/system/boot/platform/pxe_ia32/Jamfile @@ -9,7 +9,7 @@ UsePrivateHeaders [ FDirName graphics vesa ] ; UsePrivateHeaders [ FDirName storage ] ; { - local defines = _BOOT_MODE ; + local defines = _BOOT_MODE _PXE_ENV ; defines = [ FDefines $(defines) ] ; SubDirCcFlags $(defines) -Wall -Wno-multichar ; @@ -28,7 +28,6 @@ local bios_ia32_src = mmu.cpp cpu.cpp smp.cpp - smp_trampoline.S support.S video.cpp apm.cpp @@ -36,6 +35,7 @@ local bios_ia32_src = KernelMergeObject boot_platform_pxe_ia32.o : pxe_stage2.S + smp_trampoline.S $(bios_ia32_src) # generic diff --git a/src/system/boot/platform/pxe_ia32/pxe_stage1.S b/src/system/boot/platform/pxe_ia32/pxe_stage1.S index 1398595a0b..2c6509db5c 100644 --- a/src/system/boot/platform/pxe_ia32/pxe_stage1.S +++ b/src/system/boot/platform/pxe_ia32/pxe_stage1.S @@ -30,7 +30,8 @@ // 0x00000 - 0x07bff real mode IDT, stack // 0x07C00 - 0x08FFF pxehaiku (stage 1, this) // 0x09000 - 0x0FFFF scratchbuffer -// 0x10000 - 0x8CFFF pxe-haiku-loader (stage 2) +// 0x10000 - 0x8AFFF pxe-haiku-loader (stage 2) +// 0x8B000 - 0x8CFFF used by stage2 trampoline code // 0x8D000 - 0x9F7FF PXE and UNDI code and data segments // 0x9F800 - 0xA0000 extended BIOS data area @@ -40,7 +41,7 @@ .equ scratchbuffer_size, 0x7000 .equ load_addr, 0x10000 -.equ load_size_max, (0x8D000 - load_addr) +.equ load_size_max, (0x8B000 - load_addr) .code16 .text diff --git a/src/system/boot/platform/pxe_ia32/smp_trampoline.S b/src/system/boot/platform/pxe_ia32/smp_trampoline.S index 480f453b57..91ae8a5f9a 100644 --- a/src/system/boot/platform/pxe_ia32/smp_trampoline.S +++ b/src/system/boot/platform/pxe_ia32/smp_trampoline.S @@ -3,14 +3,14 @@ ** Distributed under the terms of the NewOS License. */ // expects a stack page like this: -// (stack has to be at (0x9e000) -// 0x9effc : final esp -// 0x9eff8 : page dir +// (stack has to be at (0x8c000) +// 0x8cffc : final esp +// 0x8cff8 : page dir // -// 0x9e000 - 0x9e006 : gdt descriptor -// 0x9e008 - 0x9e020 : gdt +// 0x8c000 - 0x8c006 : gdt descriptor +// 0x8c008 - 0x8c020 : gdt // -// smp_trampoline must be located at 0x9f000 +// smp_trampoline must be located at 0x8b000 .globl smp_trampoline .globl smp_trampoline_end .globl foo @@ -19,11 +19,11 @@ smp_trampoline: cli - mov $0x9e00,%ax + mov $0x8c00,%ax mov %ax,%ds -// lgdt 0x9e000 # load the gdt -.byte 0x66, 0x0f, 0x01, 0x15, 0x00, 0xe0, 0x09, 0x00 +// lgdt 0x8c000 # load the gdt +.byte 0x66, 0x0f, 0x01, 0x15, 0x00, 0xc0, 0x08, 0x00 movl %cr0,%eax orl $0x01,%eax @@ -32,7 +32,7 @@ smp_trampoline: .code32 _trampoline_32: .byte 0x66 - ljmp $0x08,$(trampoline_32 - smp_trampoline + 0x9f000) + ljmp $0x08,$(trampoline_32 - smp_trampoline + 0x8b000) trampoline_32: mov $0x10, %ax mov %ax, %ds @@ -41,7 +41,7 @@ trampoline_32: mov %ax, %gs mov %ax, %ss - movl $0x9eff8,%esp # set up the stack pointer + movl $0x8cff8,%esp # set up the stack pointer popl %eax # get the page dir movl %eax,%cr3 # set the page dir