[FREELDR]: All tabs to 4 spaces and remove trailing whitespace.

svn path=/trunk/; revision=66146
This commit is contained in:
Hermès Bélusca-Maïto
2015-02-01 22:15:32 +00:00
parent cd843a9298
commit dcf70ea86f
31 changed files with 763 additions and 778 deletions
+3 -3
View File
@@ -38,7 +38,7 @@ Changes in v1.8.25 (10/30/2004) (chorns)
Changes in v1.8.24 (09/20/2004) (hbirr)
- Implemented the driver loading by the sequence of tag entries
- Implemented the driver loading by the sequence of tag entries
in the GroupOrderList key.
Changes in v1.8.23 (30/08/2004) (ekohl)
@@ -56,7 +56,7 @@ Changes in v1.8.21 (21/05/2004) (navaraf)
- Experimental NTFS reading support with no boot code yet.
- Adjusted detection timeouts for PS/2 and RS232 to the minimum
allowed by the specifications.
- Enabled the 'Press any key to boot from CD' message in the ISO
- Enabled the 'Press any key to boot from CD' message in the ISO
boot code and show it only when some hard disk is present.
Changes in v1.8.20 (21/05/2004) (navaraf)
@@ -228,7 +228,7 @@ Changes in v1.7.6 (8/31/2002) (ekohl)
- freeldr.c, bootmgr.c, setupldr.c, makefile: Renamed
LoadBootManager() and ReactOSRunSetupLoader() to RunLoader().
Either bootmgr.o or setupldr.o is used to build freeldr.sys or
setupldr.sys
setupldr.sys
Changes in v1.7.5 (8/21/2002) (brianp)
+19 -20
View File
@@ -1,5 +1,4 @@
#include <asm.inc>
#include <arch/pc/x86common.h>
@@ -45,11 +44,11 @@ FrldrStartup:
xor rcx, rcx
call BootMain
/* We should never get here */
/* We should never get here */
stop:
jmp stop
nop
nop
jmp stop
nop
nop
PUBLIC Reboot
@@ -74,17 +73,17 @@ CallRealMode:
SwitchToReal:
/* Set sane segments */
mov ax, LMODE_DS
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
//mov ss, ax
mov ax, LMODE_DS
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
//mov ss, ax
//mov word ptr [HEX(0b8008)], HEX(0e00) + '4'
/* Save 64-bit stack pointer */
mov qword ptr [stack64], rsp
/* Save 64-bit stack pointer */
mov qword ptr [stack64], rsp
/* Step 1 - jump to compatibility segment */
jmp fword ptr [jumpvector]
@@ -97,15 +96,15 @@ SwitchToRealCompSegment:
/* Note: In fact the CPU is in 32 bit mode here. But it will interprete
the generated instructions accordingly. rax will become eax */
/* Step 2 - deactivate long mode, by disabling paging */
mov rax, cr0
and eax, HEX(7fffffff) //~0x80000000, upper bits cleared
mov cr0, rax
/* Step 2 - deactivate long mode, by disabling paging */
mov rax, cr0
and eax, HEX(7fffffff) //~0x80000000, upper bits cleared
mov cr0, rax
// mov word ptr [HEX(0b800a)], HEX(0e00) + '5'
/* Step 3 - jump to 16-bit segment to set the limit correctly */
.byte HEX(0EA) // 32bit long jmp
/* Step 3 - jump to 16-bit segment to set the limit correctly */
.byte HEX(0EA) // 32bit long jmp
AddressOfRealModeEntryPoint:
.long 0 // receives address of RealModeEntryPoint
.word HEX(20)//RMODE_CS
@@ -119,7 +118,7 @@ CallRealMode_return:
/////////////////////////////////////////
/* 64-bit stack pointer */
/* 64-bit stack pointer */
stack64:
.double STACKADDR
@@ -34,18 +34,18 @@ Int386:
mov qword ptr [r11 + 16], rdx
mov qword ptr [r11 + 24], r8
/* Save non-volatile registers */
push rbx
push rbp
push rsi
push rdi
/* Save non-volatile registers */
push rbx
push rbp
push rsi
push rdi
/* Alloc stack space for home registers */
sub rsp, 40
sub rsp, 40
//.ENDPROLOG
int386_2:
/* Copy the int vector to shared memory */
/* Copy the int vector to shared memory */
mov dword ptr [BSS_IntVector], ecx
/* Copy input registers */
@@ -41,25 +41,25 @@ PnpBiosSupported:
xor rdi, rdi
/* init rsi */
mov rsi, HEX(0F0000)
mov rsi, HEX(0F0000)
pnp_again:
mov eax, [rsi]
cmp eax, HEX(506E5024) /* "$PnP" */
cmp eax, HEX(506E5024) /* "$PnP" */
je pnp_found
cmp rsi, HEX(0FFFF0)
cmp rsi, HEX(0FFFF0)
je pnp_not_found
pnp_add:
add rsi, 16
add rsi, 16
jmp pnp_again
pnp_found:
/* first calculate the checksum */
push rsi
push HEX(21)
push HEX(21)
pop rcx
xor edx, edx
@@ -76,14 +76,14 @@ pnp_loop:
/* Calculate the bios entry point (far pointer) */
xor eax, eax
mov ax, [rsi + HEX(0F)]
shl eax, 16
mov ax, [rsi + HEX(0D)]
mov dword ptr [BSS_PnpBiosEntryPoint], eax
mov ax, [rsi + HEX(0F)]
shl eax, 16
mov ax, [rsi + HEX(0D)]
mov dword ptr [BSS_PnpBiosEntryPoint], eax
/* Store bios data segment */
mov ax, [rsi + HEX(1B)]
mov word ptr [BSS_PnpBiosDataSegment], ax
mov word ptr [BSS_PnpBiosDataSegment], ax
pnp_not_found:
mov rax, rdi
@@ -109,14 +109,14 @@ PnpBiosGetDeviceNodeCount:
call CallRealMode
xor eax, eax
mov ax, [BSS_PnpNodeSize]
mov [rcx], eax
mov ax, [BSS_PnpNodeCount]
mov [rdx], eax
mov ax, [BSS_PnpNodeSize]
mov [rcx], eax
mov ax, [BSS_PnpNodeCount]
mov [rdx], eax
mov eax, dword ptr [BSS_PnpResult]
mov eax, dword ptr [BSS_PnpResult]
ret
ret
@@ -128,29 +128,29 @@ PnpBiosGetDeviceNodeCount:
PUBLIC PnpBiosGetDeviceNode
PnpBiosGetDeviceNode:
/* get current node number */
mov al, [rcx]
mov byte ptr [BSS_PnpNodeNumber], al
/* get current node number */
mov al, [rcx]
mov byte ptr [BSS_PnpNodeNumber], al
/* convert pointer to node buffer to segment/offset */
mov rax, rdx
shr eax, 4
mov word ptr [BSS_PnpBiosBufferSegment], ax
mov rax, rdx
and eax, HEX(0f)
mov word ptr [BSS_PnpBiosBufferOffset], ax
/* convert pointer to node buffer to segment/offset */
mov rax, rdx
shr eax, 4
mov word ptr [BSS_PnpBiosBufferSegment], ax
mov rax, rdx
and eax, HEX(0f)
mov word ptr [BSS_PnpBiosBufferOffset], ax
/* Call the real mode function */
mov bx, FNID_PnpBiosGetDeviceNode
call CallRealMode
/* update node number */
mov al, byte ptr [BSS_PnpNodeNumber]
mov [rcx], al
/* update node number */
mov al, byte ptr [BSS_PnpNodeNumber]
mov [rcx], al
mov eax, [BSS_PnpResult]
mov eax, [BSS_PnpResult]
ret
ret
END
/* EOF */
@@ -106,12 +106,12 @@ WinLdrMapSpecialPages(ULONG PcrBasePage)
PHARDWARE_PDE_ARMV6 PointerPde;
PHARDWARE_LARGE_PTE_ARMV6 LargePte;
PFN_NUMBER Pfn;
/* Setup the Startup PDE */
LargePte = &PdrPage->PageDir.Pte[StartupPdePageTableIndex];
TempLargePte.PageFrameNumber = PaToLargePfn((ULONG_PTR)&PdrPage->PageDir);
*LargePte = TempLargePte;
/* Map-in the PDR */
LargePte = &PdrPage->PageDir.Pte[PdrPageTableIndex];
*LargePte = TempLargePte;
@@ -130,7 +130,7 @@ WinLdrMapSpecialPages(ULONG PcrBasePage)
*PointerPde++ = TempPde;
}
/*
/*
* Now map these page tables in PTE space (MiAddressToPte(PTE_BASE)).
* Note that they all live on a single page, since each is 1KB.
*/
@@ -156,7 +156,7 @@ WinLdrMapSpecialPages(ULONG PcrBasePage)
TempPte.PageFrameNumber = 0;
*PointerPte = TempPte;
/* TODO: Map in the kernel CPTs */
/* TODO: Map in the kernel CPTs */
return TRUE;
}
@@ -177,7 +177,7 @@ WinLdrSetupForNt(IN PLOADER_PARAMETER_BLOCK LoaderBlock,
LoaderBlock->u.Arm.SecondLevelDcacheFillSize = SecondLevelDcacheFillSize;
LoaderBlock->u.Arm.SecondLevelIcacheSize = SecondLevelIcacheSize;
LoaderBlock->u.Arm.SecondLevelIcacheFillSize = SecondLevelIcacheSize;
/* Write initial context information */
LoaderBlock->KernelStack = (ULONG_PTR)PdrPage->KernelStack;
LoaderBlock->KernelStack += KERNEL_STACK_SIZE;
@@ -248,11 +248,11 @@ VOID
WinLdrSetProcessorContext(PVOID GdtIdt,
IN ULONG Pcr,
IN ULONG Tss)
{
{
ARM_CONTROL_REGISTER ControlRegister;
ARM_TTB_REGISTER TtbRegister;
ARM_DOMAIN_REGISTER DomainRegister;
/* Set the TTBR */
TtbRegister.AsUlong = (ULONG_PTR)&PdrPage->PageDir;
ASSERT(TtbRegister.Reserved == 0);
@@ -270,5 +270,5 @@ WinLdrSetProcessorContext(PVOID GdtIdt,
ControlRegister.DCacheEnabled = TRUE;
ControlRegister.ForceAp = TRUE;
ControlRegister.ExtendedPageTables = TRUE;
KeArmControlRegisterSet(ControlRegister);
KeArmControlRegisterSet(ControlRegister);
}
+63 -63
View File
@@ -27,115 +27,115 @@ PUBLIC _DriveMapInt13HandlerStart
_DriveMapInt13HandlerStart:
Int13Handler:
push bp
mov bp, sp
push ax
push cx
push si
push bp
mov bp, sp
push ax
push cx
push si
cld
cld
/* Get callers flags from stack */
mov ax, [bp + 6]
mov word ptr cs:[CallersFlags - Int13Handler], ax
/* Get callers flags from stack */
mov ax, [bp + 6]
mov word ptr cs:[CallersFlags - Int13Handler], ax
/* Save the drive number they passed in */
mov cs:[PassedInDriveNumber - Int13Handler], dl
/* Save the drive number they passed in */
mov cs:[PassedInDriveNumber - Int13Handler], dl
/* Now we need to perform the mapping */
xor cx, cx
mov si, offset Int13HandlerMapCount - Int13Handler
/* Now we need to perform the mapping */
xor cx, cx
mov si, offset Int13HandlerMapCount - Int13Handler
/* Get the count of drives in the map list */
mov cl, cs:[si]
inc si
/* Get the count of drives in the map list */
mov cl, cs:[si]
inc si
/* If the map list is empty then just call the old int 13h handler */
cmp cl, 0
jz CallOldInt13Handler
/* If the map list is empty then just call the old int 13h handler */
cmp cl, 0
jz CallOldInt13Handler
GetMappedDriveNumberLoop:
/* Get the next drive number in the list */
lods ax, cs:[si]
/* Get the next drive number in the list */
lods ax, cs:[si]
/* Check to see if it's the one they are calling int 13h for */
cmp dl, al
/* Check to see if it's the one they are calling int 13h for */
cmp dl, al
/* If not get the next one */
jne GetMappedDriveNumberLoopNext
/* If not get the next one */
jne GetMappedDriveNumberLoopNext
/* If we get here then we have found a mapped drive */
/* Send new drive number on to the old int 13h handler */
mov dl, ah
/* If we get here then we have found a mapped drive */
/* Send new drive number on to the old int 13h handler */
mov dl, ah
/* Call BIOS Int 13 Handler */
jmp CallOldInt13Handler
/* Call BIOS Int 13 Handler */
jmp CallOldInt13Handler
GetMappedDriveNumberLoopNext:
loop GetMappedDriveNumberLoop
loop GetMappedDriveNumberLoop
CallOldInt13Handler:
/* Restore the registers we changed off the stack */
pop si
pop cx
pop ax
/* Restore the registers we changed off the stack */
pop si
pop cx
pop ax
/* Put flags onto stack */
push word ptr cs:[CallersFlags - Int13Handler]
/* Put flags onto stack */
push word ptr cs:[CallersFlags - Int13Handler]
/* Call old int 13h handler with new drive number */
.byte HEX(9a) /* lcall */
/* Call old int 13h handler with new drive number */
.byte HEX(9a) /* lcall */
PUBLIC _DriveMapOldInt13HandlerAddress
_DriveMapOldInt13HandlerAddress:
.word 0
.word 0
.word 0
.word 0
/* Update the callers flags with the values the BIOS returned */
push ax
pushf
pop ax
mov [bp + 6], ax
pop ax
/* Update the callers flags with the values the BIOS returned */
push ax
pushf
pop ax
mov [bp + 6], ax
pop ax
/* Restore the callers drive number */
mov dl, cs:[PassedInDriveNumber - Int13Handler]
/* Restore the callers drive number */
mov dl, cs:[PassedInDriveNumber - Int13Handler]
pop bp
pop bp
iret
iret
CallersFlags:
.word 0
.word 0
PassedInDriveNumber:
.byte 0
.byte 0
PUBLIC _DriveMapInt13HandlerMapList
_DriveMapInt13HandlerMapList:
Int13HandlerMapCount:
.byte 0
.byte 0
Int13HandlerDrive1:
.byte 0
.byte 0
Int13HandlerDriveNew1:
.byte 0
.byte 0
Int13HandlerDrive2:
.byte 0
.byte 0
Int13HandlerDriveNew2:
.byte 0
.byte 0
Int13HandlerDrive3:
.byte 0
.byte 0
Int13HandlerDriveNew3:
.byte 0
.byte 0
Int13HandlerDrive4:
.byte 0
.byte 0
Int13HandlerDriveNew4:
.byte 0
.byte 0
PUBLIC _DriveMapInt13HandlerEnd
_DriveMapInt13HandlerEnd:
@@ -245,13 +245,13 @@ SwitchToReal16Address:
/* 16-bit stack pointer */
stack16:
.word STACK16ADDR
.word STACK16ADDR
/* 32-bit stack pointer */
stack32:
.long STACKADDR
.align 4 /* force 4-byte alignment */
.align 4 /* force 4-byte alignment */
gdt:
/* NULL Descriptor */
.word HEX(0000)
@@ -285,18 +285,18 @@ gdt:
/* GDT table pointer */
gdtptr:
.word HEX(27) /* Limit */
.long gdt /* Base Address */
.word HEX(27) /* Limit */
.long gdt /* Base Address */
/* Real-mode IDT pointer */
rmode_idtptr:
.word HEX(3ff) /* Limit */
.long 0 /* Base Address */
.word HEX(3ff) /* Limit */
.long 0 /* Base Address */
PUBLIC i386idtptr
i386idtptr:
.word 255 /* Limit */
.long _i386Idt /* Base Address */
.word 255 /* Limit */
.long _i386Idt /* Base Address */
PUBLIC _FrldrBootDrive
_FrldrBootDrive:
@@ -33,7 +33,8 @@ char *i386ExceptionDescriptionText[] =
"Exception 12: MACHINE CHECK\n\n"
};
#define SCREEN_ATTR 0x1f
#define SCREEN_ATTR 0x1F // Bright white on blue background
void
i386PrintChar(char chr, ULONG x, ULONG y)
{
@@ -32,67 +32,67 @@ EXTERN i386CallRealMode:PROC
PUBLIC _PnpBiosSupported
_PnpBiosSupported:
push edi
push esi
push ecx
push edx
push edi
push esi
push ecx
push edx
xor edi, edi
xor edi, edi
/* init esi */
mov esi, HEX(0F0000)
/* init esi */
mov esi, HEX(0F0000)
pnp_again:
mov eax, [esi]
cmp eax, HEX(506E5024) /* "$PnP" */
je pnp_found
mov eax, [esi]
cmp eax, HEX(506E5024) /* "$PnP" */
je pnp_found
cmp esi, HEX(0FFFF0)
je pnp_not_found
cmp esi, HEX(0FFFF0)
je pnp_not_found
pnp_add:
add esi, 16
jmp pnp_again
add esi, 16
jmp pnp_again
pnp_found:
/* first calculate the checksum */
push esi
/* first calculate the checksum */
push esi
push HEX(21)
pop ecx
xor edx, edx
push HEX(21)
pop ecx
xor edx, edx
pnp_loop:
lodsb
add dl, al
loop pnp_loop
lodsb
add dl, al
loop pnp_loop
test dl, dl
pop esi
jnz pnp_add
test dl, dl
pop esi
jnz pnp_add
mov edi, esi
mov edi, esi
/* Calculate the bios entry point (far pointer) */
xor eax, eax
mov ax, [esi + HEX(0F)]
shl eax, 16
mov ax, [esi + HEX(0D)]
mov dword ptr ds:[BSS_PnpBiosEntryPoint], eax
/* Calculate the bios entry point (far pointer) */
xor eax, eax
mov ax, [esi + HEX(0F)]
shl eax, 16
mov ax, [esi + HEX(0D)]
mov dword ptr ds:[BSS_PnpBiosEntryPoint], eax
/* Store bios data segment */
mov ax, [esi + HEX(1B)]
mov word ptr ds:[BSS_PnpBiosDataSegment], ax
/* Store bios data segment */
mov ax, [esi + HEX(1B)]
mov word ptr ds:[BSS_PnpBiosDataSegment], ax
pnp_not_found:
mov eax, edi
mov eax, edi
pop edx
pop ecx
pop esi
pop edi
pop edx
pop ecx
pop esi
pop edi
ret
ret
/*
@@ -103,34 +103,34 @@ pnp_not_found:
PUBLIC _PnpBiosGetDeviceNodeCount
_PnpBiosGetDeviceNodeCount:
push ebp
mov ebp, esp
push ebp
mov ebp, esp
pusha
push es
pusha
push es
mov bx, FNID_PnpBiosGetDeviceNodeCount
call i386CallRealMode
mov esi, [ebp + 8]
mov ax, [BSS_PnpNodeSize]
movzx ecx, ax
mov [esi], ecx
mov esi, [ebp + 8]
mov ax, [BSS_PnpNodeSize]
movzx ecx, ax
mov [esi], ecx
mov esi, [ebp + 12]
mov ax, [BSS_PnpNodeCount]
movzx ecx, ax
mov [esi], ecx
mov esi, [ebp + 12]
mov ax, [BSS_PnpNodeCount]
movzx ecx, ax
mov [esi], ecx
pop es
popa
pop es
popa
mov esp, ebp
pop ebp
mov esp, ebp
pop ebp
mov eax, dword ptr [BSS_PnpResult]
mov eax, dword ptr [BSS_PnpResult]
ret
ret
/*
@@ -141,43 +141,44 @@ _PnpBiosGetDeviceNodeCount:
PUBLIC _PnpBiosGetDeviceNode
_PnpBiosGetDeviceNode:
push ebp
mov ebp, esp
push ebp
mov ebp, esp
pusha
push es
pusha
push es
/* get current node number */
mov esi, [ebp + 8]
mov al, [esi]
mov byte ptr ds:[BSS_PnpNodeNumber], al
/* get current node number */
mov esi, [ebp + 8]
mov al, [esi]
mov byte ptr ds:[BSS_PnpNodeNumber], al
/* convert pointer to node buffer to segment/offset */
mov eax, [ebp + 12]
shr eax, 4
and eax, HEX(0f000)
mov word ptr ds:[BSS_PnpBiosBufferSegment], ax
mov eax, [ebp + 12]
and eax, HEX(0ffff)
mov word ptr ds:[BSS_PnpBiosBufferOffset], ax
/* convert pointer to node buffer to segment/offset */
mov eax, [ebp + 12]
shr eax, 4
and eax, HEX(0f000)
mov word ptr ds:[BSS_PnpBiosBufferSegment], ax
mov eax, [ebp + 12]
and eax, HEX(0ffff)
mov word ptr ds:[BSS_PnpBiosBufferOffset], ax
mov bx, FNID_PnpBiosGetDeviceNode
call i386CallRealMode
/* update node number */
mov esi, [ebp + 8]
mov al, byte ptr ds:[BSS_PnpNodeNumber]
mov [esi], al
/* update node number */
mov esi, [ebp + 8]
mov al, byte ptr ds:[BSS_PnpNodeNumber]
mov [esi], al
pop es
popa
pop es
popa
mov esp, ebp
pop ebp
mov esp, ebp
pop ebp
mov eax, [BSS_PnpResult]
mov eax, [BSS_PnpResult]
ret
ret
END
/* EOF */
@@ -19,9 +19,6 @@
#include <asm.inc>
#include <arch/pc/x86common.h>
#include <ver.h>
#define SCREEN_ATTR 0x1f /* Bright white on blue background */
EXTERN _i386PrintExceptionText@12:PROC
@@ -59,10 +56,10 @@ MACRO(SAVE_CPU_REGS)
/* push KSPECIAL_REGISTERS */
/* Gdtr, Idtr, Tr, Ldtr, Reserved */
sub esp, 44
sgdt [esp]
sidt [esp + 8]
str word ptr [esp + 16]
sldt word ptr [esp + 18]
sgdt [esp]
sidt [esp + 8]
str word ptr [esp + 16]
sldt word ptr [esp + 18]
mov eax, dr7;
push eax
mov eax, dr6;
@@ -87,12 +84,12 @@ ENDM
/* Set by each exception handler to the address of the description text */
i386ExceptionIndex:
.long 0
.long 0
/************************************************************************/
i386CommonExceptionHandler:
SAVE_CPU_REGS
SAVE_CPU_REGS
lea eax, [esp + (21 * 4)] // KTRAP_FRAME
push esp // KSPECIAL_REGISTERS
@@ -100,26 +97,26 @@ i386CommonExceptionHandler:
push dword ptr ds:[i386ExceptionIndex]
call _i386PrintExceptionText@12
cli
cli
i386ExceptionHandlerHang:
hlt
jmp i386ExceptionHandlerHang
hlt
jmp i386ExceptionHandlerHang
iret
iret
MACRO(TRAP_STUB, function, index)
PUBLIC VAL(function)
&function:
push 0 // Fake error code
mov dword ptr ds:[i386ExceptionIndex], VAL(index)
jmp i386CommonExceptionHandler
mov dword ptr ds:[i386ExceptionIndex], VAL(index)
jmp i386CommonExceptionHandler
ENDM
MACRO(TRAP_STUB2, function, index)
PUBLIC VAL(function)
&function:
mov dword ptr ds:[i386ExceptionIndex], VAL(index)
jmp i386CommonExceptionHandler
mov dword ptr ds:[i386ExceptionIndex], VAL(index)
jmp i386CommonExceptionHandler
ENDM
/************************************************************************/
@@ -156,15 +153,15 @@ MACRO(BREAKPOINT_TEPLATE, functionname, mask1, mask2)
#else
\functionname:
#endif
push eax
mov eax, [esp + 8]
mov dr3, eax
mov eax, dr7
and eax, VAL(mask1)
or eax, VAL(mask2)
mov dr7, eax
pop eax
ret
push eax
mov eax, [esp + 8]
mov dr3, eax
mov eax, dr7
and eax, VAL(mask1)
or eax, VAL(mask2)
mov dr7, eax
pop eax
ret
ENDM
BREAKPOINT_TEPLATE _INSTRUCTION_BREAKPOINT1, HEX(0fff0ffff), HEX(000000303)
@@ -180,5 +177,4 @@ BREAKPOINT_TEPLATE _INSTRUCTION_BREAKPOINT4, HEX(00fffffff), HEX(0000003c0)
BREAKPOINT_TEPLATE _MEMORY_READWRITE_BREAKPOINT4, HEX(00fffffff), HEX(0300003c0)
BREAKPOINT_TEPLATE _MEMORY_WRITE_BREAKPOINT4, HEX(00fffffff), HEX(0100003c0)
END
@@ -30,16 +30,16 @@ EXTERN i386CallRealMode:PROC
PUBLIC _BootOldLinuxKernel
_BootOldLinuxKernel:
/* First we have to copy the kernel down from 0x100000 to 0x10000 */
/* The reason we can overwrite low memory is because this code */
/* executes between 0000:8000 and 0000:FFFF. That leaves space for */
/* 32k of code before we start interfering with Linux kernel address space. */
/* First we have to copy the kernel down from 0x100000 to 0x10000 */
/* The reason we can overwrite low memory is because this code */
/* executes between 0000:8000 and 0000:FFFF. That leaves space for */
/* 32k of code before we start interfering with Linux kernel address space. */
/* Get KernelSize in ECX and move the kernel down */
mov ecx, [esp + 4]
mov esi, HEX(100000)
mov edi, HEX(10000)
rep movsb
/* Get KernelSize in ECX and move the kernel down */
mov ecx, [esp + 4]
mov esi, HEX(100000)
mov edi, HEX(10000)
rep movsb
/* Fall through */
+4 -4
View File
@@ -35,16 +35,16 @@ PUBLIC _PageDirectoryEnd
#endif
_PageDirectoryStart:
_startup_pagedirectory:
.fill 4096, 1, 0
.fill 4096, 1, 0
_lowmem_pagetable:
.fill 4096, 1, 0
.fill 4096, 1, 0
_kernel_pagetable:
.fill 2*4096, 1, 0
.fill 2*4096, 1, 0
_apic_pagetable:
.fill 4096, 1, 0
.fill 4096, 1, 0
_PageDirectoryEnd:
@@ -1,38 +1,38 @@
.section ".text"
.extern PpcInit
.globl _start
.globl call_ofw
.section ".text"
.extern PpcInit
.globl _start
.globl call_ofw
_start:
sync
isync
sync
isync
lis %r1,stackend@ha
addi %r1,%r1,stackend@l
lis %r1,stackend@ha
addi %r1,%r1,stackend@l
/* Store ofw call addr */
mr %r21,%r5
lis %r10,ofw_call_addr@ha
stw %r5,ofw_call_addr@l(%r10)
/* Store ofw call addr */
mr %r21,%r5
lis %r10,ofw_call_addr@ha
stw %r5,ofw_call_addr@l(%r10)
bl zero_registers
/* Zero CTR */
mtcr %r31
bl zero_registers
lis %r3,PpcInit@ha
addi %r3,%r3,PpcInit@l
mtlr %r3
/* Zero CTR */
mtcr %r31
/* Check for ofw */
lis %r3,ofw_call_addr@ha
lwz %r3,ofw_call_addr@l(%r3)
cmpw %r3,%r31 /* Zero? */
mr %r3,%r31
beq initfp
lis %r3,call_ofw@ha
addi %r3,%r3,call_ofw@l
b bootme
lis %r3,PpcInit@ha
addi %r3,%r3,PpcInit@l
mtlr %r3
/* Check for ofw */
lis %r3,ofw_call_addr@ha
lwz %r3,ofw_call_addr@l(%r3)
cmpw %r3,%r31 /* Zero? */
mr %r3,%r31
beq initfp
lis %r3,call_ofw@ha
addi %r3,%r3,call_ofw@l
b bootme
initfp:
/* Enabling FP at this point won't hurt, and the varargs scheme we're
@@ -41,71 +41,71 @@ initfp:
ori %r0,%r0,8192
mtmsr %r0
bootme:
blr
bootme:
blr
zero_registers:
xor %r2,%r2,%r2
mr %r0,%r2
mr %r3,%r2
mr %r4,%r2
mr %r5,%r2
mr %r6,%r2
mr %r7,%r2
xor %r2,%r2,%r2
mr %r0,%r2
mr %r3,%r2
mr %r8,%r2
mr %r9,%r2
mr %r10,%r2
mr %r11,%r2
mr %r4,%r2
mr %r5,%r2
mr %r6,%r2
mr %r7,%r2
mr %r12,%r2
mr %r13,%r2
mr %r14,%r2
mr %r15,%r2
mr %r12,%r2
mr %r13,%r2
mr %r14,%r2
mr %r15,%r2
mr %r16,%r2
mr %r17,%r2
mr %r18,%r2
mr %r19,%r2
mr %r20,%r2
mr %r21,%r2
mr %r22,%r2
mr %r23,%r2
mr %r24,%r2
mr %r25,%r2
mr %r26,%r2
mr %r27,%r2
mr %r28,%r2
mr %r29,%r2
mr %r30,%r2
mr %r31,%r2
mr %r8,%r2
mr %r9,%r2
mr %r10,%r2
mr %r11,%r2
mr %r12,%r2
mr %r13,%r2
mr %r14,%r2
mr %r15,%r2
mr %r12,%r2
mr %r13,%r2
mr %r14,%r2
mr %r15,%r2
mr %r16,%r2
mr %r17,%r2
mr %r18,%r2
mr %r19,%r2
mr %r20,%r2
mr %r21,%r2
mr %r22,%r2
mr %r23,%r2
mr %r24,%r2
mr %r25,%r2
mr %r26,%r2
mr %r27,%r2
mr %r28,%r2
mr %r29,%r2
mr %r30,%r2
mr %r31,%r2
blr
blr
ofw_memory_size:
.long 0
.long 0
.long 0
.long 0
.long 0
.long 0
.long 0
.long 0
.align 4
.align 4
stack:
.space 0x4000
.space 0x4000
stackend:
.long 0,0,0,0
.globl _bss
.section ".bss2"
_bss:
.long 0
.long 0,0,0,0
.align 4
.globl _bss
.section ".bss2"
_bss:
.long 0
.align 4
@@ -209,14 +209,14 @@ ULONG PpcGetMemoryMap( PBIOS_MEMORY_MAP BiosMemoryMap,
BiosMemoryMap[slots].Length = claimed[i] - last;
slots++;
}
BiosMemoryMap[slots].Type = BiosMemoryUsable;
BiosMemoryMap[slots].BaseAddress = claimed[i];
BiosMemoryMap[slots].Length = 8 * 1024 * 1024;
total += BiosMemoryMap[slots].Length;
last =
BiosMemoryMap[slots].BaseAddress +
last =
BiosMemoryMap[slots].BaseAddress +
BiosMemoryMap[slots].Length;
slots++;
i++;
@@ -236,12 +236,12 @@ ULONG PpcGetMemoryMap( PBIOS_MEMORY_MAP BiosMemoryMap,
i,
(int)BiosMemoryMap[i].BaseAddress,
(int)BiosMemoryMap[i].Length);
}
mem_range_end = regdata[1];
printf( "Returning memory map (%d entries, %dk free, %dk total ram)\n",
printf( "Returning memory map (%d entries, %dk free, %dk total ram)\n",
slots, total / 1024, regdata[1] / 1024 );
return slots;
@@ -313,10 +313,10 @@ VOID NarrowToWide(WCHAR *wide_name, char *name)
/* Recursively copy the device tree into our representation
* It'll be passed to HAL.
*
* When NT was first done on PPC, it was on PReP hardware, which is very
*
* When NT was first done on PPC, it was on PReP hardware, which is very
* like PC hardware (really, just a PPC on a PC motherboard). HAL can guess
* the addresses of needed resources in this scheme as it can on x86.
* the addresses of needed resources in this scheme as it can on x86.
*
* Most PPC hardware doesn't assign fixed addresses to hardware, which is
* the problem that open firmware partially solves. It allows hardware makers
@@ -327,8 +327,8 @@ VOID NarrowToWide(WCHAR *wide_name, char *name)
* recording information from openfirmware to be treated as hints.
*/
VOID OfwCopyDeviceTree
(PCONFIGURATION_COMPONENT_DATA ParentKey,
char *name,
(PCONFIGURATION_COMPONENT_DATA ParentKey,
char *name,
int innode,
ULONG *BusNumber,
ULONG *DiskController,
@@ -360,7 +360,7 @@ VOID OfwCopyDeviceTree
proplen = ofw_getproplen(node, cur_name);
if (proplen > 256 || proplen < 0)
{
printf("Warning: not getting prop %s (too long: %d)\n",
printf("Warning: not getting prop %s (too long: %d)\n",
cur_name, proplen);
continue;
}
@@ -369,7 +369,7 @@ VOID OfwCopyDeviceTree
/* Get device type so we can examine it */
if (!strcmp(cur_name, "device_type"))
strcpy(devtype, (char *)data);
NarrowToWide(wide_name, cur_name);
//RegSetValue(NewKey, wide_name, REG_BINARY, data, proplen);
@@ -1,8 +1,8 @@
.section .text
.globl ofw_functions
.globl ofw_call_addr
.globl call_ofw
call_ofw:
.section .text
.globl ofw_functions
.globl ofw_call_addr
.globl call_ofw
call_ofw:
/* R3 has the function offset to call (n * 4)
* Other arg registers are unchanged. */
subi %r1,%r1,0x100
@@ -46,4 +46,3 @@ call_ofw:
lwz %r20,36(%r1)
addi %r1,%r1,0x100
blr
@@ -82,8 +82,8 @@ ULONG PpcPrepGetMemoryMap( PBIOS_MEMORY_MAP BiosMemoryMap,
// Find the last ram address in physical space ... this bypasses mapping
// but could run into non-ram objects right above ram. Usually systems
// aren't designed like that though.
for (physAddr = 0x40000, change = newStore;
(physAddr < 0x80000000) && (change == newStore);
for (physAddr = 0x40000, change = newStore;
(physAddr < 0x80000000) && (change == newStore);
physAddr += 1 << 12)
{
oldStore = GetPhys(physAddr);
@@ -106,7 +106,7 @@ ULONG PpcPrepGetMemoryMap( PBIOS_MEMORY_MAP BiosMemoryMap,
return 1;
}
/* Most PReP hardware is in standard locations, based on the corresponding
/* Most PReP hardware is in standard locations, based on the corresponding
* hardware on PCs. */
PCONFIGURATION_COMPONENT_DATA PpcPrepHwDetect() {
PCONFIGURATION_COMPONENT_DATA SystemKey;
@@ -15,11 +15,11 @@ void ide_setup( void *extension );
void print_bar( struct _pci_bar *bar );
void pci_setup
( PCONFIGURATION_COMPONENT_DATA pci_bus,
( PCONFIGURATION_COMPONENT_DATA pci_bus,
struct _pci_desc *pci_desc );
void pci_read_bar
( struct _pci_desc *pci_desc,
int bus, int dev, int fn, int bar,
( struct _pci_desc *pci_desc,
int bus, int dev, int fn, int bar,
struct _pci_bar *bar_data );
void vga_setup
@@ -10,7 +10,7 @@ struct _vga_desc {
#define VGA_HEIGHT 768
struct _vga_desc vga1_desc = { (char *)0x800003c0 };
void vga_setup( PCONFIGURATION_COMPONENT_DATA pcibus,
void vga_setup( PCONFIGURATION_COMPONENT_DATA pcibus,
struct _pci_desc *desc, struct _vga_desc *vga_desc,
int bus, int dev, int fn ) {
struct _pci_bar bar_data;
+125 -125
View File
@@ -15,26 +15,26 @@
.org 512
Startup:
cli
cli
/* Setup real mode segment registers */
xor ax, ax
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
/* Setup real mode segment registers */
xor ax, ax
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
/* Save the boot drive and partition */
mov byte ptr ds:[BSS_BootDrive], dl
mov byte ptr ds:[BSS_BootPartition], dh
/* Setup a real mode stack */
/* Setup a real mode stack */
mov sp, word ptr ds:[stack16]
/* Output first status */
mov si, offset Msg_Starting
call writestr
/* Output first status */
mov si, offset Msg_Starting
call writestr
/* Enable A20 address line */
call EnableA20
@@ -44,9 +44,9 @@ Startup:
test al, al
jnz .LongModeSupported
/* Output failure message */
mov si, offset Msg_Unsupported
call writestr
/* Output failure message */
mov si, offset Msg_Unsupported
call writestr
/* Wait for a keypress */
int HEX(16)
@@ -57,21 +57,21 @@ Msg_Unsupported:
.ascii "Press any key to reboot...", NUL
Msg_Starting:
.ascii "Starting FreeLoader...", CR, LF, NUL
.ascii "Starting FreeLoader...", CR, LF, NUL
Msg_LongModeSupported:
.ascii "Long mode support detected.", CR, LF, NUL
.LongModeSupported:
/* Output status */
mov si, offset Msg_LongModeSupported
call writestr
/* Output status */
mov si, offset Msg_LongModeSupported
call writestr
/* Load the GDT */
lgdt fword ptr [gdtptr]
/* Load the GDT */
lgdt fword ptr [gdtptr]
/* Build the startup page tables */
call BuildPageTables
call BuildPageTables
/* Store real mode entry point in shared memory */
mov dword ptr ds:[BSS_RealModeEntry], offset RealModeEntryPoint
@@ -95,9 +95,9 @@ Msg_LongModeSupported:
xor ax, ax
mov es, ax
/* Output status */
mov si, offset Msg_SwitchToLongMode
call writestr
/* Output status */
mov si, offset Msg_SwitchToLongMode
call writestr
jmp ExitToLongMode
@@ -106,36 +106,36 @@ Msg_SwitchToLongMode:
.align 8
gdt:
.word HEX(0000), HEX(0000), HEX(0000), HEX(0000) /* 00: NULL descriptor */
.word HEX(0000), HEX(0000), HEX(0000), HEX(0000) /* 08: */
.word HEX(0000), HEX(0000), HEX(9800), HEX(0020) /* 10: long mode cs */
.word HEX(ffff), HEX(0000), HEX(f300), HEX(00cf) /* 18: long mode ds */
.word HEX(FFFF), HEX(0000), HEX(9E00), HEX(0000) /* 20: 16-bit real mode CS */
.word HEX(FFFF), HEX(0000), HEX(9200), HEX(0000) /* 28: 16-bit real mode DS */
.word HEX(FFFF), HEX(0000), HEX(9B00), HEX(00CF) /* 30: compat mode cs */
.word HEX(0000), HEX(0000), HEX(0000), HEX(0000) /* 00: NULL descriptor */
.word HEX(0000), HEX(0000), HEX(0000), HEX(0000) /* 08: */
.word HEX(0000), HEX(0000), HEX(9800), HEX(0020) /* 10: long mode cs */
.word HEX(ffff), HEX(0000), HEX(f300), HEX(00cf) /* 18: long mode ds */
.word HEX(FFFF), HEX(0000), HEX(9E00), HEX(0000) /* 20: 16-bit real mode CS */
.word HEX(FFFF), HEX(0000), HEX(9200), HEX(0000) /* 28: 16-bit real mode DS */
.word HEX(FFFF), HEX(0000), HEX(9B00), HEX(00CF) /* 30: compat mode cs */
/* GDT table pointer */
gdtptr:
.word HEX(37) /* Limit */
.long offset gdt /* Base Address */
.word HEX(37) /* Limit */
.long offset gdt /* Base Address */
CheckFor64BitSupport:
/* Check if CPU supports CPUID */
pushad
pushfd
pop eax
mov ebx, eax
xor eax, HEX(00200000)
push eax
popfd
pushfd
pop eax
cmp eax,ebx
jnz .CheckForPAE
/* Check if CPU supports CPUID */
pushad
pushfd
pop eax
mov ebx, eax
xor eax, HEX(00200000)
push eax
popfd
pushfd
pop eax
cmp eax,ebx
jnz .CheckForPAE
mov si, offset .Msg_NoCpuidSupport
call writestr
call writestr
popad
xor al, al
ret
@@ -144,15 +144,15 @@ CheckFor64BitSupport:
.ascii "The system doesn't support CPUID.", CR, LF, NUL
.CheckForPAE:
/* CPUID support detected - getting the PAE/PGE */
mov eax,1 // Fn0000_0001 - PAE in EDX[6]
cpuid
and edx, HEX(00a0)
cmp edx, HEX(00a0)
je .CheckForLongMode
/* CPUID support detected - getting the PAE/PGE */
mov eax,1 // Fn0000_0001 - PAE in EDX[6]
cpuid
and edx, HEX(00a0)
cmp edx, HEX(00a0)
je .CheckForLongMode
mov si, offset .Msg_NoPAE
call writestr
call writestr
popad
xor al, al
ret
@@ -161,15 +161,15 @@ CheckFor64BitSupport:
.ascii "PAE or PGE not set.", CR, LF, NUL
.CheckForLongMode:
xor edx, edx
mov eax, HEX(80000001)
cpuid
and edx, HEX(20000000)
test edx,edx
jnz .Success
xor edx, edx
mov eax, HEX(80000001)
cpuid
and edx, HEX(20000000)
test edx,edx
jnz .Success
mov si, offset .Msg_NoLongMode
call writestr
call writestr
popad
xor al, al
ret
@@ -185,53 +185,53 @@ CheckFor64BitSupport:
BuildPageTables:
pusha
push es
pusha
push es
/* Get segment of the PML4 */
mov eax, PML4_ADDRESS / 16
mov es, ax
cld
xor di, di
/* Get segment of the PML4 */
mov eax, PML4_ADDRESS / 16
mov es, ax
cld
xor di, di
/* One entry in the PML4 pointing to PDP */
mov eax, PDP_ADDRESS
or eax, HEX(0f)
stosd
/* One entry in the PML4 pointing to PDP */
mov eax, PDP_ADDRESS
or eax, HEX(0f)
stosd
/* clear rest */
xor eax, eax
mov cx, 1023
rep stosd
/* clear rest */
xor eax, eax
mov cx, 1023
rep stosd
/* One entry in the PDP pointing to PD */
mov eax, PD_ADDRESS
or eax, HEX(0f)
stosd
/* One entry in the PDP pointing to PD */
mov eax, PD_ADDRESS
or eax, HEX(0f)
stosd
/* clear rest */
xor eax, eax
mov ecx, 1023
rep stosd
/* clear rest */
xor eax, eax
mov ecx, 1023
rep stosd
/* 512 entries in the PD, each defining a 2MB page each */
mov ecx, 512
mov eax, HEX(008f)
/* 512 entries in the PD, each defining a 2MB page each */
mov ecx, 512
mov eax, HEX(008f)
.Bpt2:
mov es: [di], eax
mov dword ptr es: [di + 4], 0
add eax, 512 * 4096 // add 512 4k pages
add di, 8
mov es: [di], eax
mov dword ptr es: [di + 4], 0
add eax, 512 * 4096 // add 512 4k pages
add di, 8
/* Loop all PDEs */
dec cx
jnz .Bpt2
/* Loop all PDEs */
dec cx
jnz .Bpt2
/* Return */
pop es
popa
ret
/* Return */
pop es
popa
ret
/******************************************************************************/
@@ -241,13 +241,13 @@ BuildPageTables:
/* This is the entry point from long mode */
RealModeEntryPoint:
/* Disable Protected Mode */
mov eax, cr0
and eax, HEX(0fffffffe) // ~0x00000001
mov cr0, eax
/* Disable Protected Mode */
mov eax, cr0
and eax, HEX(0fffffffe) // ~0x00000001
mov cr0, eax
/* Clear prefetch queue & correct CS */
ljmp16 0, offset InRealMode
/* Clear prefetch queue & correct CS */
ljmp16 0, offset InRealMode
InRealMode:
@@ -285,43 +285,43 @@ ExitToLongMode:
cli
/* Set correct segment registers */
xor ax,ax
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
mov ss,ax
xor ax,ax
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
mov ss,ax
/* Safe current stack pointer */
mov word ptr ds:[stack16], sp
/* Set PAE and PGE: 10100000b */
mov eax, HEX(00a0)
mov cr4, eax
mov eax, HEX(00a0)
mov cr4, eax
/* Point cr3 at the PML4 */
mov eax, PML4_ADDRESS
mov cr3, eax
mov eax, PML4_ADDRESS
mov cr3, eax
/* Enable long mode */
mov ecx, MSR_EFER
rdmsr
or eax, HEX(00000100)
wrmsr
mov ecx, MSR_EFER
rdmsr
or eax, HEX(00000100)
wrmsr
/* Activate long mode by enabling paging and protection simultaneously,
skipping protected mode entirely */
mov eax, cr0
or eax, HEX(80000001)
mov cr0, eax
mov eax, cr0
or eax, HEX(80000001)
mov cr0, eax
/* Clear prefetch queue & correct CS */
ljmp16 LMODE_CS, InLongMode
InLongMode:
//DB 66h, 0B8h, 18h, 00h // mov ax, LMODE_DS
//DB 66h, 8Eh, 0D8h // mov ds, ax
//DB 66h, 66h, 0C7h, 04h, 25h, 00h, 80h, 0Bh, 00h, 31h, 0Eh
//mov word ptr [HEX(b8000)], HEX(0e00) + '1'
//DB 66h, 0B8h, 18h, 00h // mov ax, LMODE_DS
//DB 66h, 8Eh, 0D8h // mov ds, ax
//DB 66h, 66h, 0C7h, 04h, 25h, 00h, 80h, 0Bh, 00h, 31h, 0Eh
//mov word ptr [HEX(b8000)], HEX(0e00) + '1'
.byte HEX(0ff), HEX(25) // opcode of 64bit indirect jump
.long 1 // relative address of LongModeEntryPoint
@@ -8,37 +8,37 @@
//.text
#define BootSectorStackTop HEX(7bf2)
#define DataAreaStartHigh 2
#define DataAreaStartLow 4
#define BiosCHSDriveSizeHigh 6
#define BiosCHSDriveSizeLow 8
#define BiosCHSDriveSize 8
#define ReadSectorsOffset 10
#define ReadClusterOffset 12
#define PutCharsOffset 14
#define BootSectorStackTop HEX(7bf2)
#define DataAreaStartHigh 2
#define DataAreaStartLow 4
#define BiosCHSDriveSizeHigh 6
#define BiosCHSDriveSizeLow 8
#define BiosCHSDriveSize 8
#define ReadSectorsOffset 10
#define ReadClusterOffset 12
#define PutCharsOffset 14
#define OEMName 3
#define BytesPerSector 11
#define SectsPerCluster 13
#define ReservedSectors 14
#define NumberOfFats 16
#define MaxRootEntries 17
#define TotalSectors 19
#define MediaDescriptor 21
#define SectorsPerFat 22
#define SectorsPerTrack 24
#define NumberOfHeads 26
#define HiddenSectors 28
#define TotalSectorsBig 32
#define BootDrive 36
#define Reserved 37
#define ExtendSig 38
#define SerialNumber 39
#define VolumeLabel 43
#define FileSystem 54
#define OEMName 3
#define BytesPerSector 11
#define SectsPerCluster 13
#define ReservedSectors 14
#define NumberOfFats 16
#define MaxRootEntries 17
#define TotalSectors 19
#define MediaDescriptor 21
#define SectorsPerFat 22
#define SectorsPerTrack 24
#define NumberOfHeads 26
#define HiddenSectors 28
#define TotalSectorsBig 32
#define BootDrive 36
#define Reserved 37
#define ExtendSig 38
#define SerialNumber 39
#define VolumeLabel 43
#define FileSystem 54
#define BootPartition HEX(7dfd)
#define BootPartition HEX(7dfd)
// This code will be stored in the first 512 bytes
@@ -82,13 +82,13 @@ LoadFile:
call IsFat12
pop ax
jnc LoadFile2
cmp ax, HEX(0ff8) // Check to see if this is the last cluster in the chain
cmp ax, HEX(0ff8) // Check to see if this is the last cluster in the chain
jmp LoadFile3
LoadFile2:
cmp ax, HEX(0fff8)
LoadFile3:
jae LoadFile_Done // If so continue, if not then read then next one
jae LoadFile_Done // If so continue, if not then read then next one
push ax
xor bx,bx // Load ROSLDR starting at 0000:8000h
push es
@@ -97,27 +97,27 @@ LoadFile3:
xor bx,bx
mov bl, [bp+SectsPerCluster]
shl bx,5 // BX = BX * 512 / 16
mov ax,es // Increment the load address by
add ax,bx // The size of a cluster
shl bx,5 // BX = BX * 512 / 16
mov ax,es // Increment the load address by
add ax,bx // The size of a cluster
mov es,ax
call IsFat12
pop ax
push es
jnc LoadFile4
call GetFatEntry12 // Get the next entry
call GetFatEntry12 // Get the next entry
jmp LoadFile5
LoadFile4:
call GetFatEntry16
LoadFile5:
pop es
jmp LoadFile // Load the next cluster (if any)
jmp LoadFile // Load the next cluster (if any)
LoadFile_Done:
mov dl, byte ptr [bp+BootDrive] // Load the boot drive into DL
mov dh, byte ptr ds:[BootPartition] // Load the boot partition into DH
mov dl, byte ptr [bp+BootDrive] // Load the boot drive into DL
mov dh, byte ptr ds:[BootPartition] // Load the boot partition into DH
/* continue where other bootsectors start */
jmp start
@@ -141,15 +141,15 @@ ReadFatIntoMemory:
// On entry AX has cluster number
// On return AX has FAT entry for that cluster
GetFatEntry16:
mov cx,2 // AX = AX * 2 (since FAT16 entries are 2 bytes)
mov cx,2 // AX = AX * 2 (since FAT16 entries are 2 bytes)
mul cx
shl dx,12
mov bx, HEX(7000)
add bx,dx
mov es,bx
mov bx,ax // Restore FAT entry offset
mov ax, es:[bx] // Get FAT entry
mov bx,ax // Restore FAT entry offset
mov ax, es:[bx] // Get FAT entry
ret
@@ -161,13 +161,13 @@ GetFatEntry12:
push ax
mov cx,ax
shr ax,1
add ax,cx // AX = AX * 1.5 (AX = AX + (AX / 2)) (since FAT12 entries are 12 bits)
add ax,cx // AX = AX * 1.5 (AX = AX + (AX / 2)) (since FAT12 entries are 12 bits)
mov bx, HEX(7000)
mov es,bx
mov bx,ax // Put FAT entry offset into BX
mov ax, es:[bx] // Get FAT entry
pop cx // Get cluster number from stack
mov bx,ax // Put FAT entry offset into BX
mov ax, es:[bx] // Get FAT entry
pop cx // Get cluster number from stack
and cx,1
jz UseLow12Bits
and ax, HEX(0fff0)
@@ -201,8 +201,8 @@ IsFat12:
// EAX now contains the number of sectors on the volume
IsFat12_2:
sub eax,ebx // Subtract data area start sector
xor edx,edx // from total sectors of volume
sub eax,ebx // Subtract data area start sector
xor edx,edx // from total sectors of volume
// EDX:EAX now contains the number of data sectors on the volume
movzx ebx, byte ptr [bp+SectsPerCluster]
@@ -220,6 +220,6 @@ IsFat12_Done:
msgLoading:
.ascii "Loading FreeLoader...", CR, LF, NUL
.org 510 // Pad to 510 bytes
.word HEX(0aa55) // BootSector signature
.org 510 // Pad to 510 bytes
.word HEX(0aa55) // BootSector signature
@@ -1,21 +1,21 @@
Empty8042:
.word HEX(00eb), HEX(00eb) // jmp $+2, jmp $+2
.word HEX(00eb), HEX(00eb) // jmp $+2, jmp $+2
in al, HEX(64)
cmp al, HEX(0ff) // legacy-free machine without keyboard
jz Empty8042_ret // controllers on Intel Macs read back 0xFF
cmp al, HEX(0ff) // legacy-free machine without keyboard
jz Empty8042_ret // controllers on Intel Macs read back 0xFF
test al, 2
jnz Empty8042
Empty8042_ret:
ret
ret
EnableA20:
pusha
call Empty8042
mov al, HEX(0D1) // command write
mov al, HEX(0D1) // command write
out HEX(064), al
call Empty8042
mov al, HEX(0DF) // A20 on
mov al, HEX(0DF) // A20 on
out HEX(060), al
call Empty8042
popa
@@ -26,32 +26,32 @@ EnableA20:
* si = pointer to zero terminated string
*/
writestr:
pushfd
pushad
pushfd
pushad
writestr_top:
lodsb
and al, al
jz writestr_end
call writechr
jmp short writestr_top
lodsb
and al, al
jz writestr_end
call writechr
jmp short writestr_top
writestr_end:
popad
popfd
ret
popad
popfd
ret
/*
* writechr
* al = character to output
*/
writechr:
pushf
pusha
mov ah, HEX(0E)
xor bx, bx
int HEX(10)
popa
popf
ret
pushf
pusha
mov ah, HEX(0E)
xor bx, bx
int HEX(10)
popa
popf
ret
//
// writehex[248]: Write a hex number in (AL, AX, EAX) to the console
@@ -93,13 +93,13 @@ writehex_common:
ret
Reboot:
cli
cli
/* Set the word at location 40h:72h to 0 (cold reboot) */
mov word ptr ds:[HEX(0472)], HEX(0)
/* Set the word at location 40h:72h to 0 (cold reboot) */
mov word ptr ds:[HEX(0472)], HEX(0)
/* and jump to location F000h:FFF0h in ROM */
ljmp16 HEX(0F000), HEX(0FFF0)
/* and jump to location F000h:FFF0h in ROM */
ljmp16 HEX(0F000), HEX(0FFF0)
ChainLoadBiosBootSectorCode:
@@ -58,50 +58,50 @@ RealModeEntryPoint:
/* This is the entry point from protected mode */
switch_to_real16:
/* Restore segment registers to correct limit */
mov ax, RMODE_DS
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
/* Restore segment registers to correct limit */
mov ax, RMODE_DS
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
/* Disable Protected Mode */
mov eax, cr0
and eax, CR0_PE_CLR
mov cr0, eax
/* Disable Protected Mode */
mov eax, cr0
and eax, CR0_PE_CLR
mov cr0, eax
/* Clear prefetch queue & correct CS */
ljmp16 0, inrmode
/* Clear prefetch queue & correct CS */
ljmp16 0, inrmode
inrmode:
/* Set real mode segments */
xor ax, ax
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
xor ax, ax
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
/* Clear out the high 16-bits of ESP */
/* This is needed because I have one */
/* machine that hangs when booted to dos if */
/* anything other than 0x0000 is in the high */
/* 16-bits of ESP. Even though real-mode */
/* code should only use SP and not ESP. */
xor esp, esp
/* Clear out the high 16-bits of ESP */
/* This is needed because I have one */
/* machine that hangs when booted to dos if */
/* anything other than 0x0000 is in the high */
/* 16-bits of ESP. Even though real-mode */
/* code should only use SP and not ESP. */
xor esp, esp
/* Restore real mode stack */
mov sp, word ptr ds:[stack16]
mov sp, word ptr ds:[stack16]
/* Load IDTR with real mode value */
/* Load IDTR with real mode value */
#ifdef _USE_ML
lidt fword ptr rmode_idtptr
#else
lidt rmode_idtptr
lidt rmode_idtptr
#endif
sti /* These are ok now */
sti /* These are ok now */
/* Do the callback, specified by bx */
shl bx, 1
@@ -155,47 +155,47 @@ stack16:
.word STACK16ADDR
.align 4 /* force 4-byte alignment */
.align 4 /* force 4-byte alignment */
gdt:
/* NULL Descriptor */
.word HEX(0000)
.word HEX(0000)
.word HEX(0000)
.word HEX(0000)
/* NULL Descriptor */
.word HEX(0000)
.word HEX(0000)
.word HEX(0000)
.word HEX(0000)
/* 32-bit flat CS */
.word HEX(FFFF)
.word HEX(0000)
.word HEX(9A00)
.word HEX(00CF)
/* 32-bit flat CS */
.word HEX(FFFF)
.word HEX(0000)
.word HEX(9A00)
.word HEX(00CF)
/* 32-bit flat DS */
.word HEX(FFFF)
.word HEX(0000)
.word HEX(9200)
.word HEX(00CF)
/* 32-bit flat DS */
.word HEX(FFFF)
.word HEX(0000)
.word HEX(9200)
.word HEX(00CF)
/* 16-bit real mode CS */
.word HEX(FFFF)
.word HEX(0000)
.word HEX(9E00)
.word HEX(0000)
/* 16-bit real mode CS */
.word HEX(FFFF)
.word HEX(0000)
.word HEX(9E00)
.word HEX(0000)
/* 16-bit real mode DS */
.word HEX(FFFF)
.word HEX(0000)
.word HEX(9200)
.word HEX(0000)
/* 16-bit real mode DS */
.word HEX(FFFF)
.word HEX(0000)
.word HEX(9200)
.word HEX(0000)
/* GDT table pointer */
gdtptr:
.word HEX(27) /* Limit */
.word HEX(27) /* Limit */
.word gdt, 0 /* Base Address */
/* Real-mode IDT pointer */
rmode_idtptr:
.word HEX(3ff) /* Limit */
.long 0 /* Base Address */
.word HEX(3ff) /* Limit */
.long 0 /* Base Address */
#include "int386.inc"
#include "pxe.inc"
@@ -6,75 +6,75 @@
#define EFLAGS_SF HEX(80)
Int386:
/* Save all registers + segment registers */
push ds
push es
push fs
push gs
pushad
/* Save all registers + segment registers */
push ds
push es
push fs
push gs
pushad
/* Get the interupt vector and patch the opcode */
mov al, byte ptr ds:[BSS_IntVector]
mov byte ptr ds:[Int386_vector_opcode], al
/* Get current EFLAGS and mask CF, ZF and SF */
pushf
pop cx
and cx, not (EFLAGS_CF or EFLAGS_ZF or EFLAGS_SF)
/* Get current EFLAGS and mask CF, ZF and SF */
pushf
pop cx
and cx, not (EFLAGS_CF or EFLAGS_ZF or EFLAGS_SF)
/* Get flags CF, ZF and SF from the REGS structure */
mov ax, word ptr cs:[BSS_RegisterSet + REGS_EFLAGS]
and ax, (EFLAGS_CF or EFLAGS_ZF or EFLAGS_SF)
/* Get flags CF, ZF and SF from the REGS structure */
mov ax, word ptr cs:[BSS_RegisterSet + REGS_EFLAGS]
and ax, (EFLAGS_CF or EFLAGS_ZF or EFLAGS_SF)
/* Combine flags and set them */
or ax, cx
push ax
popf
/* Combine flags and set them */
or ax, cx
push ax
popf
/* Setup the registers */
mov ax, word ptr cs:[BSS_RegisterSet + REGS_DS]
mov ds, ax
mov ax, word ptr cs:[BSS_RegisterSet + REGS_ES]
mov es, ax
mov ax, word ptr cs:[BSS_RegisterSet + REGS_FS]
mov fs, ax
mov ax, word ptr cs:[BSS_RegisterSet + REGS_GS]
mov gs, ax
/* Setup the registers */
mov ax, word ptr cs:[BSS_RegisterSet + REGS_DS]
mov ds, ax
mov ax, word ptr cs:[BSS_RegisterSet + REGS_ES]
mov es, ax
mov ax, word ptr cs:[BSS_RegisterSet + REGS_FS]
mov fs, ax
mov ax, word ptr cs:[BSS_RegisterSet + REGS_GS]
mov gs, ax
mov eax, dword ptr cs:[BSS_RegisterSet + REGS_EAX]
mov ebx, dword ptr cs:[BSS_RegisterSet + REGS_EBX]
mov ecx, dword ptr cs:[BSS_RegisterSet + REGS_ECX]
mov edx, dword ptr cs:[BSS_RegisterSet + REGS_EDX]
mov esi, dword ptr cs:[BSS_RegisterSet + REGS_ESI]
mov edi, dword ptr cs:[BSS_RegisterSet + REGS_EDI]
// Don't setup ebp, we only use it as output!
mov eax, dword ptr cs:[BSS_RegisterSet + REGS_EAX]
mov ebx, dword ptr cs:[BSS_RegisterSet + REGS_EBX]
mov ecx, dword ptr cs:[BSS_RegisterSet + REGS_ECX]
mov edx, dword ptr cs:[BSS_RegisterSet + REGS_EDX]
mov esi, dword ptr cs:[BSS_RegisterSet + REGS_ESI]
mov edi, dword ptr cs:[BSS_RegisterSet + REGS_EDI]
// Don't setup ebp, we only use it as output!
/* Call the interrupt vector */
/*int Int386_vector*/
.byte HEX(0cd)
/* Call the interrupt vector */
/*int Int386_vector*/
.byte HEX(0cd)
Int386_vector_opcode:
.byte 00
.byte 00
/* Save the registers */
mov dword ptr cs:[BSS_RegisterSet + REGS_EAX], eax
mov dword ptr cs:[BSS_RegisterSet + REGS_EBX], ebx
mov dword ptr cs:[BSS_RegisterSet + REGS_ECX], ecx
mov dword ptr cs:[BSS_RegisterSet + REGS_EDX], edx
mov dword ptr cs:[BSS_RegisterSet + REGS_ESI], esi
mov dword ptr cs:[BSS_RegisterSet + REGS_EDI], edi
mov dword ptr cs:[BSS_RegisterSet + REGS_EBP], ebp
/* Save the registers */
mov dword ptr cs:[BSS_RegisterSet + REGS_EAX], eax
mov dword ptr cs:[BSS_RegisterSet + REGS_EBX], ebx
mov dword ptr cs:[BSS_RegisterSet + REGS_ECX], ecx
mov dword ptr cs:[BSS_RegisterSet + REGS_EDX], edx
mov dword ptr cs:[BSS_RegisterSet + REGS_ESI], esi
mov dword ptr cs:[BSS_RegisterSet + REGS_EDI], edi
mov dword ptr cs:[BSS_RegisterSet + REGS_EBP], ebp
mov ax, ds
mov word ptr cs:[BSS_RegisterSet + REGS_DS], ax
mov ax, es
mov word ptr cs:[BSS_RegisterSet + REGS_ES], ax
mov ax, fs
mov word ptr cs:[BSS_RegisterSet + REGS_FS], ax
mov ax, gs
mov word ptr cs:[BSS_RegisterSet + REGS_GS], ax
mov ax, ds
mov word ptr cs:[BSS_RegisterSet + REGS_DS], ax
mov ax, es
mov word ptr cs:[BSS_RegisterSet + REGS_ES], ax
mov ax, fs
mov word ptr cs:[BSS_RegisterSet + REGS_FS], ax
mov ax, gs
mov word ptr cs:[BSS_RegisterSet + REGS_GS], ax
pushfd
pop dword ptr cs:[BSS_RegisterSet + REGS_EFLAGS]
pushfd
pop dword ptr cs:[BSS_RegisterSet + REGS_EFLAGS]
popad
pop gs
@@ -1,16 +1,15 @@
BootLinuxKernel:
// dl must be set to the boot drive
/* Load segment registers */
cli
mov bx, HEX(9000)
mov ds, bx
mov es, bx
mov fs, bx
mov gs, bx
mov ss, bx
mov sp, HEX(9000)
/* Load segment registers */
cli
mov bx, HEX(9000)
mov ds, bx
mov es, bx
mov fs, bx
mov gs, bx
mov ss, bx
mov sp, HEX(9000)
ljmp16 HEX(9020), HEX(0000)
ljmp16 HEX(9020), HEX(0000)
@@ -1,58 +1,56 @@
PnpBiosGetDeviceNodeCount:
mov ax, word ptr ds:[BSS_PnpBiosDataSegment]
push ax
mov ax, word ptr ds:[BSS_PnpBiosDataSegment]
push ax
push cs
mov ax, BSS_PnpNodeSize
push ax
push cs
mov ax, BSS_PnpNodeSize
push ax
push cs
mov ax, BSS_PnpNodeCount
push ax
push cs
mov ax, BSS_PnpNodeCount
push ax
push 0
push 0
call dword ptr ds:[BSS_PnpBiosEntryPoint]
add sp, 12
call dword ptr ds:[BSS_PnpBiosEntryPoint]
add sp, 12
movzx ecx, ax
mov dword ptr ds:[BSS_PnpResult], ecx
movzx ecx, ax
mov dword ptr ds:[BSS_PnpResult], ecx
ret
PnpBiosGetDeviceNode:
/* push bios segment */
mov ax, word ptr ds:[BSS_PnpBiosDataSegment]
push ax
/* push bios segment */
mov ax, word ptr ds:[BSS_PnpBiosDataSegment]
push ax
/* push control flag */
push 1
/* push control flag */
push 1
/* push pointer to node buffer (segment/offset) */
mov ax, word ptr ds:[BSS_PnpBiosBufferSegment]
push ax
mov ax, word ptr ds:[BSS_PnpBiosBufferOffset]
push ax
/* push pointer to node buffer (segment/offset) */
mov ax, word ptr ds:[BSS_PnpBiosBufferSegment]
push ax
mov ax, word ptr ds:[BSS_PnpBiosBufferOffset]
push ax
/* push pointer to node number (segment/offset) */
push cs
mov ax, BSS_PnpNodeNumber
push ax
/* push pointer to node number (segment/offset) */
push cs
mov ax, BSS_PnpNodeNumber
push ax
/* push function number */
push 1
/* push function number */
push 1
/* call entry point */
call dword ptr ds:[BSS_PnpBiosEntryPoint]
add sp, 14
/* call entry point */
call dword ptr ds:[BSS_PnpBiosEntryPoint]
add sp, 14
movzx ecx, ax
mov dword ptr ds:[BSS_PnpResult], ecx
movzx ecx, ax
mov dword ptr ds:[BSS_PnpResult], ecx
ret
@@ -17,17 +17,16 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
PxeCallApi:
mov ax, word ptr ds:[BSS_PxeBufferSegment]
push ax
mov ax, word ptr ds:[BSS_PxeBufferOffset]
push ax
mov ax, word ptr ds:[BSS_PxeFunction]
push ax
call dword ptr ds:[BSS_PxeEntryPoint]
add esp, 6
mov word ptr ds:[BSS_PxeResult], ax
mov ax, word ptr ds:[BSS_PxeBufferSegment]
push ax
mov ax, word ptr ds:[BSS_PxeBufferOffset]
push ax
mov ax, word ptr ds:[BSS_PxeFunction]
push ax
call dword ptr ds:[BSS_PxeEntryPoint]
add esp, 6
mov word ptr ds:[BSS_PxeResult], ax
ret
+1 -1
View File
@@ -18,7 +18,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef _M_ARM
#include <freeldr.h>
+5 -12
View File
@@ -17,15 +17,13 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef __ASM__
#pragma once
#endif
/* just some stuff */
#define VERSION "FreeLoader v3.0"
#define COPYRIGHT "Copyright (C) 1998-2007 ReactOS Team"
/* Just some stuff */
#define VERSION "FreeLoader v3.0"
#define COPYRIGHT "Copyright (C) 1998-2007 ReactOS Team"
#define AUTHOR_EMAIL "<www.reactos.org>"
#define BY_AUTHOR "by ReactOS Team"
#define BY_AUTHOR "by ReactOS Team"
// FreeLoader version defines
//
@@ -38,9 +36,4 @@
#define FREELOADER_MINOR_VERSION 0
#define FREELOADER_PATCH_VERSION 0
#ifndef __ASM__
PCHAR GetFreeLoaderVersionString(VOID);
#endif // __ASM__
PCHAR GetFreeLoaderVersionString(VOID);
+2 -2
View File
@@ -226,13 +226,13 @@ VOID
UiDrawProgressBar(IN ULONG Left,
IN ULONG Top,
IN ULONG Right,
IN ULONG Bottom,
IN ULONG Bottom,
IN ULONG Position,
IN ULONG Range,
IN PCHAR ProgressText)
{
ULONG i, ProgressBarWidth;
/* Calculate the width of the bar proper */
ProgressBarWidth = (Right - Left) - 3;
+1 -1
View File
@@ -154,7 +154,7 @@ const UIVTBL MiniTuiVtbl =
TuiEditBox,
TuiTextToColor,
TuiTextToFillStyle,
MiniTuiDrawBackdrop, /* no FadeIn */
MiniTuiDrawBackdrop, /* no FadeIn */
TuiFadeOut,
TuiDisplayMenu,
MiniTuiDrawMenu,
@@ -97,7 +97,7 @@ WinLdrPortInitialize(IN ULONG BaudRate,
}
}
else
{
{
/* Pick correct port for address */
PortAddress = (PUCHAR)0x2F8;
if (CpDoesPortExist(PortAddress))
@@ -182,17 +182,17 @@ WinLdrInitializeHeadlessPort(VOID)
{
case 2:
LoaderRedirectionInformation.PortAddress = (PUCHAR)0x2F8;
break;
break;
case 3:
LoaderRedirectionInformation.PortAddress = (PUCHAR)0x3E8;
break;
break;
case 4:
LoaderRedirectionInformation.PortAddress = (PUCHAR)0x2E8;
break;
break;
default:
default:
LoaderRedirectionInformation.PortAddress = (PUCHAR)0x3F8;
break;
}
@@ -218,7 +218,7 @@ WinLdrInitializeHeadlessPort(VOID)
{
/* Port seems usable, set it up and get the BIOS GUID */
WinLdrEnableFifo(WinLdrTerminalDeviceId, TRUE);
WinLdrLoadGUID(&LoaderRedirectionInformation.SystemGUID);
/* Calculate delay in us based on the baud, assume 9600 if none given */
@@ -297,7 +297,7 @@ WinLdrSetupEms(IN PCHAR BootOptions)
else
{
LoaderRedirectionInformation.BaudRate = 9600;
}
}
}
/* Enable headless support if parameters were found */