Author: tkreuzer Date: Wed Jul 23 21:18:44 2008 New Revision: 34726
URL: http://svn.reactos.org/svn/reactos?rev=34726&view=rev Log: - implement _alloca (untested), ChainLoadBiosBootSectorCode, SoftReboot - copy drvmap.S, i386cpu.S, i386idt.S, i386pnp.S, i386trap.S, mb.S
Added: branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/_alloca.S (with props) branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/boot.S (with props) branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/drvmap.S (with props) branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/i386cpu.S (with props) branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/i386idt.S (with props) branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/i386pnp.S (with props) branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/i386trap.S (with props) branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/mb.S (with props)
Added: branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/_alloca.S URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/boot/f... ============================================================================== --- branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/_alloca.S (added) +++ branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/_alloca.S [iso-8859-1] Wed Jul 23 21:18:44 2008 @@ -1,0 +1,36 @@ +/* stuff needed for libgcc on win32. */ +.intel_syntax noprefix + +/*#ifdef L_chkstk*/ +#ifdef WIN32 + + .global ___chkstk + .global __alloca +___chkstk: +__alloca: + push rcx /* save temp */ + mov rcx, rsp /* get sp */ + add rcx, 8 /* and point to return addr */ + +probe: + cmp rax, 0x1000 /* > 4k ?*/ + jb done + + sub rcx, 0x1000 /* yes, move pointer down 4k*/ + or qword ptr [rcx], 0x0 /* probe there */ + sub rax, 0x1000 /* decrement count */ + jmp probe /* and do it again */ + +done: + sub rcx, rax + or qword ptr [rcx], 0x0 /* less that 4k, just peek here */ + + mov rax, rsp + mov rsp, rcx /* decrement stack */ + + mov rcx, [rax] /* recover saved temp */ + mov rax, [rax + 8]/* get return address */ + jmp [rax] + + +#endif
Propchange: branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/_alloca.S ------------------------------------------------------------------------------ svn:eol-style = native
Added: branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/boot.S URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/boot/f... ============================================================================== --- branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/boot.S (added) +++ branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/boot.S [iso-8859-1] Wed Jul 23 21:18:44 2008 @@ -1,0 +1,64 @@ +/* + * FreeLoader + * Copyright (C) 1998-2002 Brian Palmer brianp@sginet.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + .text + .code16 + +#define ASM +#include <arch.h> + + +EXTERN(_ChainLoadBiosBootSectorCode) + .code64 + + call x86_64_SwitchToReal + .code16 + + /* Set the boot drive */ + mov dl, _BootDrive + + /* Load segment registers */ + cli + mov bx, 0x0000 + mov ds, bx + mov es, bx + mov fs, bx + mov gs, bx + mov ss, bx + mov sp, 0x7C00 + +// ljmpl $0x0000,$0x7C00 + jmp 0x7c00:0x0000 + +EXTERN(_SoftReboot) + .code64 + + call x86_64_SwitchToReal + .code16 + + mov ax, 0x40 + mov ds, ax + mov si, 0x72 + + // Set the word at location 40:72 to 1234h + mov word ptr [si], 0x1234 + + // and jump to location FFFF:0 in ROM +// ljmpl $0xFFFF,$0x0000 + jmp 0xffff: 0x0000
Propchange: branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/boot.S ------------------------------------------------------------------------------ svn:eol-style = native
Added: branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/drvmap.S URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/boot/f... ============================================================================== --- branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/drvmap.S (added) +++ branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/drvmap.S [iso-8859-1] Wed Jul 23 21:18:44 2008 @@ -1,0 +1,132 @@ +/* + * FreeLoader + * Copyright (C) 1998-2002 Brian Palmer brianp@sginet.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + .text + .code16 + +#define ASM +#include <arch.h> + + +EXTERN(_DriveMapInt13HandlerStart) +Int13Handler: + + pushw %bp + movw %sp,%bp + pushw %ax + pushw %cx + pushw %si + + cld + + /* Get callers flags from stack */ + movw 0x06(%bp),%ax + movw %ax,%cs:(CallersFlags - Int13Handler) + + /* Save the drive number they passed in */ + movb %dl,%cs:(PassedInDriveNumber - Int13Handler) + + /* Now we need to perform the mapping */ + xorw %cx,%cx + movw $(Int13HandlerMapCount - Int13Handler),%si + /* Get the count of drives in the map list */ + movb %cs:(%si),%cl + incw %si + + /* If the map list is empty then just call the old int 13h handler */ + cmpb $0,%cl + jz CallOldInt13Handler + +GetMappedDriveNumberLoop: + + /* Get the next drive number in the list */ + lodsw %cs:(%si),%ax + /* Check to see if it's the one they are calling int 13h for */ + cmpb %al,%dl + /* 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 */ + movb %ah,%dl + /* Call BIOS Int 13 Handler */ + jmp CallOldInt13Handler + +GetMappedDriveNumberLoopNext: + loop GetMappedDriveNumberLoop + +CallOldInt13Handler: + /* Restore the registers we changed off the stack */ + popw %si + popw %cx + popw %ax + + /* Put flags onto stack */ + pushw %cs:(CallersFlags - Int13Handler) + + /* Call old int 13h handler with new drive number */ + .byte 0x9a /* lcall */ +EXTERN(_DriveMapOldInt13HandlerAddress) + .word 0 + .word 0 + + /* Update the callers flags with the values the BIOS returned */ + pushw %ax + pushf + popw %ax + movw %ax,0x06(%bp) + popw %ax + /* Restore the callers drive number */ + movb %cs:(PassedInDriveNumber - Int13Handler),%dl + + popw %bp + + iret + +CallersFlags: + .word 0 + +PassedInDriveNumber: + .byte 0 + +EXTERN(_DriveMapInt13HandlerMapList) +Int13HandlerMapCount: + .byte 0 + +Int13HandlerDrive1: + .byte 0 +Int13HandlerDriveNew1: + .byte 0 + +Int13HandlerDrive2: + .byte 0 +Int13HandlerDriveNew2: + .byte 0 + +Int13HandlerDrive3: + .byte 0 +Int13HandlerDriveNew3: + .byte 0 + +Int13HandlerDrive4: + .byte 0 +Int13HandlerDriveNew4: + .byte 0 + +EXTERN(_DriveMapInt13HandlerEnd)
Propchange: branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/drvmap.S ------------------------------------------------------------------------------ svn:eol-style = native
Added: branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/i386cpu.S URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/boot/f... ============================================================================== --- branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/i386cpu.S (added) +++ branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/i386cpu.S [iso-8859-1] Wed Jul 23 21:18:44 2008 @@ -1,0 +1,131 @@ +/* + * FreeLoader + * Copyright (C) 2003 Eric Kohl + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + .text + .code16 + +#define ASM + +#include <arch.h> + +/* + * U32 CpuidSupported(VOID); + * + * RETURNS: + * 0x00000001: CPU supports the CPUID instruction + * 0x00000300: Found 80386 CPU + * 0x00000400: Found 80486 CPU without CPUID support + */ + +EXTERN(_CpuidSupported) + .code32 + + pushl %ecx /* save ECX */ + + pushfl /* push original EFLAGS */ + popl %eax /* get original EFLAGS */ + movl %eax,%ecx /* save original EFLAGS */ + xorl $0x40000,%eax /* flip AC bit in EFLAGS */ + pushl %eax /* save new EFLAGS value on stack */ + popfl /* replace current EFLAGS value */ + + pushfl /* get new EFLAGS */ + popl %eax /* store new EFLAGS in EAX */ + xorl %ecx, %eax /* can't toggle AC bit, processor=80386 */ + + movl $0x300,%eax /* return processor id */ + jz NoCpuid /* jump if 80386 processor */ + + pushl %ecx + popfl /* restore AC bit in EFLAGS first */ + + movl %ecx,%eax /* get original EFLAGS */ + xorl $0x200000,%eax /* flip ID bit in EFLAGS */ + pushl %eax /* save new EFLAGS value on stack */ + popfl /* replace current EFLAGS value */ + pushfl /* get new EFLAGS */ + popl %eax /* store new EFLAGS in EAX */ + xorl %ecx,%eax /* can't toggle ID bit, */ + + movl $0x400,%eax /* return processor id */ + je NoCpuid /* processor=80486 */ + + movl $1,%eax /* CPUID supported */ + +NoCpuid: + pushl %ecx + popfl /* restore EFLAGS */ + popl %ecx /* retore ECX */ + + ret + + +/* + * VOID GetCpuid(U32 Level, U32 *eax, U32 *ebx, U32 *ecx, U32 *edx); + */ + +EXTERN(_GetCpuid) + .code32 + + pushl %ebp + movl %esp,%ebp + + pushl %eax + pushl %ebx + pushl %ecx + pushl %edx + pushl %esi + + movl 0x08(%ebp),%eax + + cpuid + + movl 0x0C(%ebp),%esi + movl %eax,(%esi) + + movl 0x10(%ebp),%esi + movl %ebx,(%esi) + + movl 0x14(%ebp),%esi + movl %ecx,(%esi) + + movl 0x18(%ebp),%esi + movl %edx,(%esi) + + popl %esi + popl %edx + popl %ecx + popl %ebx + popl %eax + + movl %ebp,%esp + popl %ebp + ret + + +/* + * U64 RDTSC(VOID); + */ + +EXTERN(_RDTSC) + .code32 + rdtsc + ret + +/* EOF */
Propchange: branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/i386cpu.S ------------------------------------------------------------------------------ svn:eol-style = native
Added: branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/i386idt.S URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/boot/f... ============================================================================== --- branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/i386idt.S (added) +++ branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/i386idt.S [iso-8859-1] Wed Jul 23 21:18:44 2008 @@ -1,0 +1,224 @@ +/* + * FreeLoader + * Copyright (C) 1998-2002 Brian Palmer brianp@sginet.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + .text + .code16 + +#define ASM +#include <arch.h> + + + .p2align 2 /* force 4-byte alignment */ +EXTERN(i386idt) + /* Exception 0 - Divide By Zero */ + .word i386DivideByZero /* Offset 0 - 15 */ + .word 0x0008 /* Selector */ + .word 0x8e00 /* Flags, Zero Byte */ + .word 0x0000 /* Offset 16 - 31 */ + + /* Exception 1 - Debug Exception */ + .word i386DebugException /* Offset 0 - 15 */ + .word 0x0008 /* Selector */ + .word 0x8e00 /* Zero byte, flags */ + .word 0x0000 /* Offset 16 - 31 */ + + /* Exception 2 - NMI */ + .word i386NMIException /* Offset 0 - 15 */ + .word 0x0008 /* Selector */ + .word 0x8e00 /* Zero byte, flags */ + .word 0x0000 /* Offset 16 - 31 */ + + /* Exception 3 - Breakpoint (INT 3) */ + .word i386Breakpoint /* Offset 0 - 15 */ + .word 0x0008 /* Selector */ + .word 0x8e00 /* Zero byte, flags */ + .word 0x0000 /* Offset 16 - 31 */ + + /* Exception 4 - Overflow (INTO with EFLAGS[OF] set) */ + .word i386Overflow /* Offset 0 - 15 */ + .word 0x0008 /* Selector */ + .word 0x8e00 /* Zero byte, flags */ + .word 0x0000 /* Offset 16 - 31 */ + + /* Exception 5 - Bound Exception */ + .word i386BoundException /* Offset 0 - 15 */ + .word 0x0008 /* Selector */ + .word 0x8e00 /* Zero byte, flags */ + .word 0x0000 /* Offset 16 - 31 */ + + /* Exception 6 - Invalid Opcode */ + .word i386InvalidOpcode /* Offset 0 - 15 */ + .word 0x0008 /* Selector */ + .word 0x8e00 /* Zero byte, flags */ + .word 0x0000 /* Offset 16 - 31 */ + + /* Exception 7 - FPU Not Available */ + .word i386FPUNotAvailable /* Offset 0 - 15 */ + .word 0x0008 /* Selector */ + .word 0x8e00 /* Zero byte, flags */ + .word 0x0000 /* Offset 16 - 31 */ + + /* Exception 8 - Double Fault */ + .word i386DoubleFault /* Offset 0 - 15 */ + .word 0x0008 /* Selector */ + .word 0x8e00 /* Zero byte, flags */ + .word 0x0000 /* Offset 16 - 31 */ + + /* Exception 9 - Coprocessor Segment Overrun */ + .word i386CoprocessorSegment /* Offset 0 - 15 */ + .word 0x0008 /* Selector */ + .word 0x8e00 /* Zero byte, flags */ + .word 0x0000 /* Offset 16 - 31 */ + + /* Exception 10 (0x0A) - Invalid TSS */ + .word i386InvalidTSS /* Offset 0 - 15 */ + .word 0x0008 /* Selector */ + .word 0x8e00 /* Zero byte, flags */ + .word 0x0000 /* Offset 16 - 31 */ + + /* Exception 11 (0x0B) - Segment Not Present */ + .word i386SegmentNotPresent /* Offset 0 - 15 */ + .word 0x0008 /* Selector */ + .word 0x8e00 /* Zero byte, flags */ + .word 0x0000 /* Offset 16 - 31 */ + + /* Exception 12 (0x0C) - Stack Exception */ + .word i386StackException /* Offset 0 - 15 */ + .word 0x0008 /* Selector */ + .word 0x8e00 /* Zero byte, flags */ + .word 0x0000 /* Offset 16 - 31 */ + + /* Exception 13 (0x0D) - General Protection Fault */ + .word i386GeneralProtectionFault /* Offset 0 - 15 */ + .word 0x0008 /* Selector */ + .word 0x8e00 /* Zero byte, flags */ + .word 0x0000 /* Offset 16 - 31 */ + + /* Exception 14 (0x0E) - Page Fault */ + .word i386PageFault /* Offset 0 - 15 */ + .word 0x0008 /* Selector */ + .word 0x8e00 /* Zero byte, flags */ + .word 0x0000 /* Offset 16 - 31 */ + + /* Exception 15 (0x0F) - Reserved */ + .word 0x0000 /* Offset 0 - 15 */ + .word 0x0000 /* Selector */ + .word 0x0000 /* Zero byte, flags */ + .word 0x0000 /* Offset 16 - 31 */ + + /* Exception 16 (0x10) - Coprocessor Error */ + .word i386CoprocessorError /* Offset 0 - 15 */ + .word 0x0008 /* Selector */ + .word 0x8e00 /* Zero byte, flags */ + .word 0x0000 /* Offset 16 - 31 */ + + /* Exception 17 (0x11) - Alignment Check */ + .word i386AlignmentCheck /* Offset 0 - 15 */ + .word 0x0008 /* Selector */ + .word 0x8e00 /* Zero byte, flags */ + .word 0x0000 /* Offset 16 - 31 */ + + /* Exception 18 (0x12) - Machine Check */ + .word i386MachineCheck /* Offset 0 - 15 */ + .word 0x0008 /* Selector */ + .word 0x8e00 /* Zero byte, flags */ + .word 0x0000 /* Offset 16 - 31 */ + + /* Exception 19 (0x13) - Reserved */ + .word 0x0000 /* Offset 0 - 15 */ + .word 0x0000 /* Selector */ + .word 0x0000 /* Zero byte, flags */ + .word 0x0000 /* Offset 16 - 31 */ + + /* Exception 20 (0x14) - Reserved */ + .word 0x0000 /* Offset 0 - 15 */ + .word 0x0000 /* Selector */ + .word 0x0000 /* Zero byte, flags */ + .word 0x0000 /* Offset 16 - 31 */ + + /* Exception 21 (0x15) - Reserved */ + .word 0x0000 /* Offset 0 - 15 */ + .word 0x0000 /* Selector */ + .word 0x0000 /* Zero byte, flags */ + .word 0x0000 /* Offset 16 - 31 */ + + /* Exception 22 (0x16) - Reserved */ + .word 0x0000 /* Offset 0 - 15 */ + .word 0x0000 /* Selector */ + .word 0x0000 /* Zero byte, flags */ + .word 0x0000 /* Offset 16 - 31 */ + + /* Exception 23 (0x17) - Reserved */ + .word 0x0000 /* Offset 0 - 15 */ + .word 0x0000 /* Selector */ + .word 0x0000 /* Zero byte, flags */ + .word 0x0000 /* Offset 16 - 31 */ + + /* Exception 24 (0x18) - Reserved */ + .word 0x0000 /* Offset 0 - 15 */ + .word 0x0000 /* Selector */ + .word 0x0000 /* Zero byte, flags */ + .word 0x0000 /* Offset 16 - 31 */ + + /* Exception 25 (0x19) - Reserved */ + .word 0x0000 /* Offset 0 - 15 */ + .word 0x0000 /* Selector */ + .word 0x0000 /* Zero byte, flags */ + .word 0x0000 /* Offset 16 - 31 */ + + /* Exception 26 (0x1A) - Reserved */ + .word 0x0000 /* Offset 0 - 15 */ + .word 0x0000 /* Selector */ + .word 0x0000 /* Zero byte, flags */ + .word 0x0000 /* Offset 16 - 31 */ + + /* Exception 27 (0x1B) - Reserved */ + .word 0x0000 /* Offset 0 - 15 */ + .word 0x0000 /* Selector */ + .word 0x0000 /* Zero byte, flags */ + .word 0x0000 /* Offset 16 - 31 */ + + /* Exception 28 (0x1C) - Reserved */ + .word 0x0000 /* Offset 0 - 15 */ + .word 0x0000 /* Selector */ + .word 0x0000 /* Zero byte, flags */ + .word 0x0000 /* Offset 16 - 31 */ + + /* Exception 29 (0x1D) - Reserved */ + .word 0x0000 /* Offset 0 - 15 */ + .word 0x0000 /* Selector */ + .word 0x0000 /* Zero byte, flags */ + .word 0x0000 /* Offset 16 - 31 */ + + /* Exception 30 (0x1E) - Reserved */ + .word 0x0000 /* Offset 0 - 15 */ + .word 0x0000 /* Selector */ + .word 0x0000 /* Zero byte, flags */ + .word 0x0000 /* Offset 16 - 31 */ + + /* Exception 31 (0x1F) - Reserved */ + .word 0x0000 /* Offset 0 - 15 */ + .word 0x0000 /* Selector */ + .word 0x0000 /* Zero byte, flags */ + .word 0x0000 /* Offset 16 - 31 */ + +/* IDT table pointer */ +EXTERN(i386idtptr) + .word (i386idtptr-i386idt) /* Limit */ + .long i386idt /* Base Address */
Propchange: branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/i386idt.S ------------------------------------------------------------------------------ svn:eol-style = native
Added: branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/i386pnp.S URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/boot/f... ============================================================================== --- branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/i386pnp.S (added) +++ branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/i386pnp.S [iso-8859-1] Wed Jul 23 21:18:44 2008 @@ -1,0 +1,258 @@ +/* + * FreeLoader + * Copyright (C) 2003 Eric Kohl + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + .text + .code16 + +#define ASM + +#include <arch.h> + + +/* + * U32 PnpBiosSupported(VOID); + * + * RETURNS: + */ +_pnp_bios_entry_point: + .long 0 +_pnp_bios_data_segment: + .word 0 + +EXTERN(_PnpBiosSupported) + .code64 + + push rdi + push rsi + push rcx + push rdx + + xor edi, edi + + /* init esi */ + mov esi, 0xF0000 + +pnp_again: + mov eax, [%esi] + cmp eax, 0x506E5024 /* "$PnP" */ + je pnp_found + + cmp esi, 0xFFFF0 + je pnp_not_found + +pnp_add: + add esi, 0x10 + jmp pnp_again + +pnp_found: + /* first calculate the checksum */ + push rsi + + push 0x21 + pop rcx + xor edx, edx + +pnp_loop: + lodsb + add dl, al + loop pnp_loop + + test dl, dl + pop rsi + jnz pnp_add + + mov edi, esi + + /* Calculate the bios entry point (far pointer) */ + xor eax, eax + mov ax, [esi + 0x0F] + shl eax, 16 + mov ax, [esi + 0x0D] + mov _pnp_bios_entry_point, eax + + /* Store bios data segment */ + mov ax, [esi + 0x1B] + mov _pnp_bios_data_segment, ax + +pnp_not_found: + mov eax, edi + + pop rdx + pop rcx + pop rsi + pop rdi + + ret + + +/* + * U32 PnpBiosGetDeviceNodeCount(U32 *NodeSize, U32 *NodeCount); + * + * RETURNS: + */ +_pnp_result: + .long 0 +_pnp_node_size: + .word 0 +_pnp_node_count: + .word 0 + +EXTERN(_PnpBiosGetDeviceNodeCount) + .code64 + + push rbp + mov rbp, rsp + +// pushal FIXME +// push es + + call x86_64_SwitchToReal + .code16 + + mov ax, _pnp_bios_data_segment + push ax + + push cs + mov ax, _pnp_node_size + push ax + + push cs + mov ax, _pnp_node_count + push ax + + push 0 + + call [_pnp_bios_entry_point] + add sp, 12 + + movzx ecx, ax + mov _pnp_result, ecx + + call x86_16_SwitchToLong + .code64 + + mov esi, [rbp + 0x08] + mov ax, _pnp_node_size + movzx ecx, ax + mov [rsi], ecx + + mov rsi, [ebp + 0x0C] + mov ax, _pnp_node_count + movzx ecx, ax + mov [rsi], eax + +// pop es +// popal + + mov rsp, rbp + pop rbp + + xor rax, rax + mov eax, _pnp_result + + ret + + +/* + * U32 PnpBiosGetDeviceNode(U8 *NodeId, U8 *NodeBuffer); + * + * RETURNS: + */ +_pnp_buffer_segment: + .word 0 +_pnp_buffer_offset: + .word 0 + +_pnp_node_number: + .byte 0 + +EXTERN(_PnpBiosGetDeviceNode) + .code64 + + push rbp + mov rbp, rsp + +// pushal +// push es + + /* get current node number */ + mov rsi, [rbp + 0x08] + mov al, [rsi] + mov _pnp_node_number, al + + /* convert pointer to node buffer to segment/offset */ + mov eax, [rbp + 0x0C] + shr eax, 4 + and eax, 0xf000 + mov _pnp_buffer_segment , ax + mov eax, [rbp + 0x0C] + and eax, 0xffff + mov _pnp_buffer_offset, ax + + call x86_64_SwitchToReal + .code16 + + /* push bios segment */ + mov ax, _pnp_bios_data_segment + push ax + + /* push control flag */ + push 0x0001 + + /* push pointer to node buffer (segment/offset) */ + mov ax, _pnp_buffer_segment + push ax + mov ax, _pnp_buffer_offset + push ax + + /* push pointer to node number (segment/offset) */ + push cs + mov ax, _pnp_node_number + push ax + + /* push function number */ + push 1 + + /* call entry point */ + call [_pnp_bios_entry_point] + add sp, 14 + + movzx ecx, ax + mov _pnp_result, ecx + + call x86_16_SwitchToLong + .code64 + + /* update node number */ + mov rsi, [rbp + 0x08] + mov al, _pnp_node_number + mov [rsi], al + +// pop es +// popal + + mov rsp, rbp + pop rbp + + xor rax, rax + mov eax, _pnp_result + + ret + +/* EOF */
Propchange: branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/i386pnp.S ------------------------------------------------------------------------------ svn:eol-style = native
Added: branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/i386trap.S URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/boot/f... ============================================================================== --- branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/i386trap.S (added) +++ branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/i386trap.S [iso-8859-1] Wed Jul 23 21:18:44 2008 @@ -1,0 +1,942 @@ +/* + * FreeLoader + * Copyright (C) 1998-2002 Brian Palmer brianp@sginet.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + .text + .code16 + +#define ASM +#include <arch.h> +#include <ver.h> + +#define SCREEN_ATTR 0x1f /* Bright white on blue background */ + +.macro SAVE_CPU_REGS + movl %eax,i386_EAX + movl %ebx,i386_EBX + movl %ecx,i386_ECX + movl %edx,i386_EDX + movl %esp,i386_ESP + movl %ebp,i386_EBP + movl %esi,i386_ESI + movl %edi,i386_EDI + movw %ds,%ax + movw %ax,i386_DS + movw %es,%ax + movw %ax,i386_ES + movw %fs,%ax + movw %ax,i386_FS + movw %gs,%ax + movw %ax,i386_GS + movw %ss,%ax + movw %ax,i386_SS + popl %eax + movl %eax,i386_EIP + popl %eax + movw %ax,i386_CS + popl %eax + movl %eax,i386_EFLAGS + movl %cr0,%eax + movl %eax,i386_CR0 + //movl %cr1,%eax + //movl %eax,i386_CR1 + movl %cr2,%eax + movl %eax,i386_CR2 + movl %cr3,%eax + movl %eax,i386_CR3 + movl %dr0,%eax + movl %eax,i386_DR0 + movl %dr1,%eax + movl %eax,i386_DR1 + movl %dr2,%eax + movl %eax,i386_DR2 + movl %dr3,%eax + movl %eax,i386_DR3 + movl %dr6,%eax + movl %eax,i386_DR6 + movl %dr7,%eax + movl %eax,i386_DR7 + sgdt i386_GDTR + sidt i386_IDTR + sldt i386_LDTR + str i386_TR +.endm + + + +i386ExceptionHandlerText: + .ascii "An error occured in FreeLoader\n" + .ascii VERSION + .ascii "\n" + .asciz "Report this error to the ReactOS Development mailing list ros-dev@reactos.org\n\n" + +i386DivideByZeroText: + .asciz "Exception 00: DIVIDE BY ZERO\n\n" +i386DebugExceptionText: + .asciz "Exception 01: DEBUG EXCEPTION\n\n" +i386NMIExceptionText: + .asciz "Exception 02: NON-MASKABLE INTERRUPT EXCEPTION\n\n" +i386BreakpointText: + .asciz "Exception 03: BREAKPOINT (INT 3)\n\n" +i386OverflowText: + .asciz "Exception 04: OVERFLOW\n\n" +i386BoundExceptionText: + .asciz "Exception 05: BOUND EXCEPTION\n\n" +i386InvalidOpcodeText: + .asciz "Exception 06: INVALID OPCODE\n\n" +i386FPUNotAvailableText: + .asciz "Exception 07: FPU NOT AVAILABLE\n\n" +i386DoubleFaultText: + .asciz "Exception 08: DOUBLE FAULT\n\n" +i386CoprocessorSegmentText: + .asciz "Exception 09: COPROCESSOR SEGMENT OVERRUN\n\n" +i386InvalidTSSText: + .asciz "Exception 0A: INVALID TSS\n\n" +i386SegmentNotPresentText: + .asciz "Exception 0B: SEGMENT NOT PRESENT\n\n" +i386StackExceptionText: + .asciz "Exception 0C: STACK EXCEPTION\n\n" +i386GeneralProtectionFaultText: + .asciz "Exception 0D: GENERAL PROTECTION FAULT\n\n" +i386PageFaultText: + .asciz "Exception 0E: PAGE FAULT\n\n" +i386CoprocessorErrorText: + .asciz "Exception 10: COPROCESSOR ERROR\n\n" +i386AlignmentCheckText: + .asciz "Exception 11: ALIGNMENT CHECK\n\n" +i386MachineCheckText: + .asciz "Exception 12: MACHINE CHECK\n\n" + +i386_EAX_Text: + .asciz "EAX: " +i386_EBX_Text: + .asciz "EBX: " +i386_ECX_Text: + .asciz "ECX: " +i386_EDX_Text: + .asciz "EDX: " +i386_ESP_Text: + .asciz " ESP: " +i386_EBP_Text: + .asciz " EBP: " +i386_ESI_Text: + .asciz " ESI: " +i386_EDI_Text: + .asciz " EDI: " +i386_CS_Text: + .asciz "CS: " +i386_DS_Text: + .asciz "DS: " +i386_ES_Text: + .asciz "ES: " +i386_FS_Text: + .asciz "FS: " +i386_GS_Text: + .asciz "GS: " +i386_SS_Text: + .asciz "SS: " +i386_EFLAGS_Text: + .asciz " EFLAGS: " +i386_EIP_Text: + .asciz " EIP: " +i386_ERROR_CODE_Text: + .asciz " ERROR CODE: " +i386_CR0_Text: + .asciz " CR0: " +i386_CR1_Text: + .asciz " CR1: " +i386_CR2_Text: + .asciz " CR2: " +i386_CR3_Text: + .asciz " CR3: " +i386_DR0_Text: + .asciz " DR0: " +i386_DR1_Text: + .asciz " DR1: " +i386_DR2_Text: + .asciz " DR2: " +i386_DR3_Text: + .asciz " DR3: " +i386_DR6_Text: + .asciz " DR6: " +i386_DR7_Text: + .asciz " DR7: " +i386_GDTR_Text: + .asciz " GDTR Base: " +i386_IDTR_Text: + .asciz " IDTR Base: " +i386_Limit_Text: + .asciz " Limit: " +i386_LDTR_Text: + .asciz " LDTR: " +i386_TR_Text: + .asciz " TR: " + +i386FramesText: + .asciz "Frames:\n" + +/* Set by each exception handler to the address of the description text */ +i386ExceptionDescriptionText: + .long 0 + +/* Used to store the contents of all the registers when an exception occurs */ +i386_EAX: + .long 0 +i386_EBX: + .long 0 +i386_ECX: + .long 0 +i386_EDX: + .long 0 +i386_ESP: + .long 0 +i386_EBP: + .long 0 +i386_ESI: + .long 0 +i386_EDI: + .long 0 +i386_CS: + .word 0 +i386_DS: + .word 0 +i386_ES: + .word 0 +i386_FS: + .word 0 +i386_GS: + .word 0 +i386_SS: + .word 0 +i386_EFLAGS: + .long 0 +i386_EIP: + .long 0 +i386_ERROR_CODE: + .long 0 +i386_CR0: + .long 0 +i386_CR1: + .long 0 +i386_CR2: + .long 0 +i386_CR3: + .long 0 +i386_DR0: + .long 0 +i386_DR1: + .long 0 +i386_DR2: + .long 0 +i386_DR3: + .long 0 +i386_DR6: + .long 0 +i386_DR7: + .long 0 +i386_GDTR: + .word 0 + .long 0 +i386_IDTR: + .word 0 + .long 0 +i386_LDTR: + .word 0 +i386_TR: + .word 0 + +/* Used to store the current X and Y position on the screen */ +i386_ScreenPosX: + .long 0 +i386_ScreenPosY: + .long 0 + +/************************************************************************/ +i386CommonExceptionHandler: + .code32 + + SAVE_CPU_REGS + + pushl $SCREEN_ATTR + call _MachVideoClearScreen + add $4,%esp + + movl $i386ExceptionHandlerText,%esi + call i386PrintText + + movl i386ExceptionDescriptionText,%esi + call i386PrintText + + movl $i386_EAX_Text,%esi + call i386PrintText + movl i386_EAX,%eax + call i386PrintHexDword // Display EAX + movl $i386_ESP_Text,%esi + call i386PrintText + movl i386_ESP,%eax + call i386PrintHexDword // Display ESP + movl $i386_CR0_Text,%esi + call i386PrintText + movl i386_CR0,%eax + call i386PrintHexDword // Display CR0 + movl $i386_DR0_Text,%esi + call i386PrintText + movl i386_DR0,%eax + call i386PrintHexDword // Display DR0 + movl $0,i386_ScreenPosX + incl i386_ScreenPosY + movl $i386_EBX_Text,%esi + call i386PrintText + movl i386_EBX,%eax + call i386PrintHexDword // Display EBX + movl $i386_EBP_Text,%esi + call i386PrintText + movl i386_EBP,%eax + call i386PrintHexDword // Display EBP + movl $i386_CR1_Text,%esi + call i386PrintText + movl i386_CR1,%eax + call i386PrintHexDword // Display CR1 + movl $i386_DR1_Text,%esi + call i386PrintText + movl i386_DR1,%eax + call i386PrintHexDword // Display DR1 + movl $0,i386_ScreenPosX + incl i386_ScreenPosY + movl $i386_ECX_Text,%esi + call i386PrintText + movl i386_ECX,%eax + call i386PrintHexDword // Display ECX + movl $i386_ESI_Text,%esi + call i386PrintText + movl i386_ESI,%eax + call i386PrintHexDword // Display ESI + movl $i386_CR2_Text,%esi + call i386PrintText + movl i386_CR2,%eax + call i386PrintHexDword // Display CR2 + movl $i386_DR2_Text,%esi + call i386PrintText + movl i386_DR2,%eax + call i386PrintHexDword // Display DR2 + movl $0,i386_ScreenPosX + incl i386_ScreenPosY + movl $i386_EDX_Text,%esi + call i386PrintText + movl i386_EDX,%eax + call i386PrintHexDword // Display EDX + movl $i386_EDI_Text,%esi + call i386PrintText + movl i386_EDI,%eax + call i386PrintHexDword // Display EDI + movl $i386_CR3_Text,%esi + call i386PrintText + movl i386_CR3,%eax + call i386PrintHexDword // Display CR3 + movl $i386_DR3_Text,%esi + call i386PrintText + movl i386_DR3,%eax + call i386PrintHexDword // Display DR3 + incl i386_ScreenPosY + movl $55,i386_ScreenPosX + movl $i386_DR6_Text,%esi + call i386PrintText + movl i386_DR6,%eax + call i386PrintHexDword // Display DR6 + incl i386_ScreenPosY + movl $55,i386_ScreenPosX + movl $i386_DR7_Text,%esi + call i386PrintText + movl i386_DR7,%eax + call i386PrintHexDword // Display DR7 + movl $0,i386_ScreenPosX + incl i386_ScreenPosY + incl i386_ScreenPosY + movl $i386_CS_Text,%esi + call i386PrintText + movw i386_CS,%ax + call i386PrintHexWord // Display CS + movl $i386_EIP_Text,%esi + call i386PrintText + movl i386_EIP,%eax + call i386PrintHexDword // Display EIP + movl $0,i386_ScreenPosX + incl i386_ScreenPosY + movl $i386_DS_Text,%esi + call i386PrintText + movw i386_DS,%ax + call i386PrintHexWord // Display DS + movl $i386_ERROR_CODE_Text,%esi + call i386PrintText + movl i386_ERROR_CODE,%eax + call i386PrintHexDword // Display ERROR CODE + movl $0,i386_ScreenPosX + incl i386_ScreenPosY + movl $i386_ES_Text,%esi + call i386PrintText + movw i386_ES,%ax + call i386PrintHexWord // Display ES + movl $i386_EFLAGS_Text,%esi + call i386PrintText + movl i386_EFLAGS,%eax + call i386PrintHexDword // Display EFLAGS + movl $0,i386_ScreenPosX + incl i386_ScreenPosY + movl $i386_FS_Text,%esi + call i386PrintText + movw i386_FS,%ax + call i386PrintHexWord // Display FS + movl $i386_GDTR_Text,%esi + call i386PrintText + movl i386_GDTR+2,%eax + call i386PrintHexDword // Display GDTR Base + movl $i386_Limit_Text,%esi + call i386PrintText + movw i386_GDTR,%ax + call i386PrintHexWord // Display GDTR Limit + movl $0,i386_ScreenPosX + incl i386_ScreenPosY + movl $i386_GS_Text,%esi + call i386PrintText + movw i386_GS,%ax + call i386PrintHexWord // Display GS + movl $i386_IDTR_Text,%esi + call i386PrintText + movl i386_IDTR+2,%eax + call i386PrintHexDword // Display IDTR Base + movl $i386_Limit_Text,%esi + call i386PrintText + movw i386_IDTR,%ax + call i386PrintHexWord // Display IDTR Limit + movl $0,i386_ScreenPosX + incl i386_ScreenPosY + movl $i386_SS_Text,%esi + call i386PrintText + movw i386_SS,%ax + call i386PrintHexWord // Display SS + movl $i386_LDTR_Text,%esi + call i386PrintText + movw i386_LDTR,%ax + call i386PrintHexWord // Display LDTR + movl $i386_TR_Text,%esi + call i386PrintText + movw i386_TR,%ax + call i386PrintHexWord // Display TR + movl $0,i386_ScreenPosX + incl i386_ScreenPosY + incl i386_ScreenPosY + call i386PrintFrames // Display frames + incl i386_ScreenPosY + incl i386_ScreenPosY + + cli +i386ExceptionHandlerHang: + hlt + jmp i386ExceptionHandlerHang + + iret + +i386PrintFrames: + movl $0,i386_ScreenPosX + movl $i386FramesText,%esi + call i386PrintText + + movl i386_EBP,%edi +printnextframe: + test %edi,%edi + je nomoreframes + movl $STACK32ADDR,%eax + cmpl %edi,%eax + jbe nomoreframes + movl 4(%edi),%eax + pushl %edi + call i386PrintHexDword // Display frame + popl %edi + incl i386_ScreenPosX + incl i386_ScreenPosX + movl 0(%edi),%edi + jmp printnextframe +nomoreframes: + ret + +/************************************************************************/ +/* AL = Char to display */ +/************************************************************************/ +i386PrintChar: + .code32 + + pushl i386_ScreenPosY + pushl i386_ScreenPosX + pushl $SCREEN_ATTR + andl $0xff,%eax + pushl %eax + call _MachVideoPutChar + addl $16,%esp + + ret + +/************************************************************************/ +/* ESI = Address of text to display */ +/************************************************************************/ +i386PrintText: + .code32 + +i386PrintTextLoop: + lodsb + + // Check for end of string char + cmp $0,%al + je i386PrintTextDone + + // Check for newline char + cmp $0x0a,%al + jne i386PrintTextLoop2 + incl i386_ScreenPosY + movl $0,i386_ScreenPosX + jmp i386PrintTextLoop + +i386PrintTextLoop2: + call i386PrintChar + incl i386_ScreenPosX + + jmp i386PrintTextLoop + +i386PrintTextDone: + + ret + +/************************************************************************/ +/* Prints the value in EAX on the screen in hex */ +/************************************************************************/ +i386PrintHexDword: + .code32 + + call i386PrintHex1 + +i386PrintHex1: + call i386PrintHex2 +i386PrintHex2: + call i386PrintHex3 +i386PrintHex3: + movb $4,%cl + rol %cl,%eax + push %eax + andb $0x0f,%al + movl $i386PrintHexTable,%ebx + xlat /*$i386PrintHexTable*/ + call i386PrintChar + incl i386_ScreenPosX + pop %eax + + ret + +i386PrintHexTable: + .ascii "0123456789ABCDEF" + +/************************************************************************/ +/* Prints the value in AX on the screen in hex */ +/************************************************************************/ +i386PrintHexWord: + .code32 + + call i386PrintHexWord1 +i386PrintHexWord1: + call i386PrintHexWord2 +i386PrintHexWord2: + movb $4,%cl + rol %cl,%ax + push %eax + andb $0x0f,%al + movl $i386PrintHexTable,%ebx + xlat /*$i386PrintHexTable*/ + call i386PrintChar + incl i386_ScreenPosX + pop %eax + + ret + +/************************************************************************/ +/* Prints the value in AL on the screen in hex */ +/************************************************************************/ +i386PrintHexByte: + .code32 + + call i386PrintHexByte1 +i386PrintHexByte1: + movb $4,%cl + rol %cl,%al + push %eax + andb $0x0f,%al + movl $i386PrintHexTable,%ebx + xlat /*$i386PrintHexTable*/ + call i386PrintChar + incl i386_ScreenPosX + pop %eax + + ret + +/************************************************************************/ +EXTERN(i386DivideByZero) + .code32 + + movl $i386DivideByZeroText,i386ExceptionDescriptionText + jmp i386CommonExceptionHandler + +/************************************************************************/ +EXTERN(i386DebugException) + .code32 + + movl $i386DebugExceptionText,i386ExceptionDescriptionText + jmp i386CommonExceptionHandler + +/************************************************************************/ +EXTERN(i386NMIException) + .code32 + + movl $i386NMIExceptionText,i386ExceptionDescriptionText + jmp i386CommonExceptionHandler + +/************************************************************************/ +EXTERN(i386Breakpoint) + .code32 + + movl $i386BreakpointText,i386ExceptionDescriptionText + jmp i386CommonExceptionHandler + +/************************************************************************/ +EXTERN(i386Overflow) + .code32 + + movl $i386OverflowText,i386ExceptionDescriptionText + jmp i386CommonExceptionHandler + +/************************************************************************/ +EXTERN(i386BoundException) + .code32 + + movl $i386BoundExceptionText,i386ExceptionDescriptionText + jmp i386CommonExceptionHandler + +/************************************************************************/ +EXTERN(i386InvalidOpcode) + .code32 + + movl $i386InvalidOpcodeText,i386ExceptionDescriptionText + jmp i386CommonExceptionHandler + +/************************************************************************/ +EXTERN(i386FPUNotAvailable) + .code32 + + movl $i386FPUNotAvailableText,i386ExceptionDescriptionText + jmp i386CommonExceptionHandler + +/************************************************************************/ +EXTERN(i386DoubleFault) + .code32 + + popl %eax + movl %eax,i386_ERROR_CODE + + movl $i386DoubleFaultText,i386ExceptionDescriptionText + jmp i386CommonExceptionHandler + +/************************************************************************/ +EXTERN(i386CoprocessorSegment) + .code32 + + movl $i386CoprocessorSegmentText,i386ExceptionDescriptionText + jmp i386CommonExceptionHandler + +/************************************************************************/ +EXTERN(i386InvalidTSS) + .code32 + + popl %eax + movl %eax,i386_ERROR_CODE + + movl $i386InvalidTSSText,i386ExceptionDescriptionText + jmp i386CommonExceptionHandler + +/************************************************************************/ +EXTERN(i386SegmentNotPresent) + .code32 + + popl %eax + movl %eax,i386_ERROR_CODE + + movl $i386SegmentNotPresentText,i386ExceptionDescriptionText + jmp i386CommonExceptionHandler + +/************************************************************************/ +EXTERN(i386StackException) + .code32 + + popl %eax + movl %eax,i386_ERROR_CODE + + movl $i386StackExceptionText,i386ExceptionDescriptionText + jmp i386CommonExceptionHandler + +/************************************************************************/ +EXTERN(i386GeneralProtectionFault) + .code32 + + popl %eax + movl %eax,i386_ERROR_CODE + + movl $i386GeneralProtectionFaultText,i386ExceptionDescriptionText + jmp i386CommonExceptionHandler + +/************************************************************************/ +EXTERN(i386PageFault) + .code32 + + popl %eax + movl %eax,i386_ERROR_CODE + + movl $i386PageFaultText,i386ExceptionDescriptionText + jmp i386CommonExceptionHandler + +/************************************************************************/ +EXTERN(i386CoprocessorError) + .code32 + + movl $i386CoprocessorErrorText,i386ExceptionDescriptionText + jmp i386CommonExceptionHandler + +/************************************************************************/ +EXTERN(i386AlignmentCheck) + .code32 + + movl $i386AlignmentCheckText,i386ExceptionDescriptionText + jmp i386CommonExceptionHandler + +/************************************************************************/ +EXTERN(i386MachineCheck) + .code32 + + movl $i386MachineCheckText,i386ExceptionDescriptionText + jmp i386CommonExceptionHandler + +/************************************************************************ + * DEBUGGING SUPPORT FUNCTIONS + ************************************************************************/ +EXTERN(_INSTRUCTION_BREAKPOINT1) + .code32 + + pushl %eax + + movl 8(%esp),%eax + + movl %eax,%dr0 + movl %dr7,%eax + andl $0xfff0ffff,%eax + orl $0x00000303,%eax + movl %eax,%dr7 + + popl %eax + + ret + +EXTERN(_MEMORY_READWRITE_BREAKPOINT1) + .code32 + + pushl %eax + + movl 8(%esp),%eax + + movl %eax,%dr0 + movl %dr7,%eax + andl $0xfff0ffff,%eax + orl $0x00030303,%eax + movl %eax,%dr7 + + popl %eax + + ret + +EXTERN(_MEMORY_WRITE_BREAKPOINT1) + .code32 + + pushl %eax + + movl 8(%esp),%eax + + movl %eax,%dr0 + movl %dr7,%eax + andl $0xfff0ffff,%eax + orl $0x00010303,%eax + movl %eax,%dr7 + + popl %eax + + ret + +EXTERN(_INSTRUCTION_BREAKPOINT2) + .code32 + + pushl %eax + + movl 8(%esp),%eax + + movl %eax,%dr1 + movl %dr7,%eax + andl $0xff0fffff,%eax + orl $0x0000030c,%eax + movl %eax,%dr7 + + popl %eax + + ret + +EXTERN(_MEMORY_READWRITE_BREAKPOINT2) + .code32 + + pushl %eax + + movl 8(%esp),%eax + + movl %eax,%dr1 + movl %dr7,%eax + andl $0xff0fffff,%eax + orl $0x0030030c,%eax + movl %eax,%dr7 + + popl %eax + + ret + +EXTERN(_MEMORY_WRITE_BREAKPOINT2) + .code32 + + pushl %eax + + movl 8(%esp),%eax + + movl %eax,%dr1 + movl %dr7,%eax + andl $0xff0fffff,%eax + orl $0x0010030c,%eax + movl %eax,%dr7 + + popl %eax + + ret + +EXTERN(_INSTRUCTION_BREAKPOINT3) + .code32 + + pushl %eax + + movl 8(%esp),%eax + + movl %eax,%dr2 + movl %dr7,%eax + andl $0xf0ffffff,%eax + orl $0x00000330,%eax + movl %eax,%dr7 + + popl %eax + + ret + +EXTERN(_MEMORY_READWRITE_BREAKPOINT3) + .code32 + + pushl %eax + + movl 8(%esp),%eax + + movl %eax,%dr2 + movl %dr7,%eax + andl $0xf0ffffff,%eax + orl $0x03000330,%eax + movl %eax,%dr7 + + popl %eax + + ret + +EXTERN(_MEMORY_WRITE_BREAKPOINT3) + .code32 + + pushl %eax + + movl 8(%esp),%eax + + movl %eax,%dr2 + movl %dr7,%eax + andl $0xf0ffffff,%eax + orl $0x01000330,%eax + movl %eax,%dr7 + + popl %eax + + ret + +EXTERN(_INSTRUCTION_BREAKPOINT4) + .code32 + + pushl %eax + + movl 8(%esp),%eax + + movl %eax,%dr3 + movl %dr7,%eax + andl $0x0fffffff,%eax + orl $0x000003c0,%eax + movl %eax,%dr7 + + popl %eax + + ret + +EXTERN(_MEMORY_READWRITE_BREAKPOINT4) + .code32 + + pushl %eax + + movl 8(%esp),%eax + + movl %eax,%dr3 + movl %dr7,%eax + andl $0x0fffffff,%eax + orl $0x300003c0,%eax + movl %eax,%dr7 + + popl %eax + + ret + +EXTERN(_MEMORY_WRITE_BREAKPOINT4) + .code32 + + pushl %eax + + movl 8(%esp),%eax + + movl %eax,%dr3 + movl %dr7,%eax + andl $0x0fffffff,%eax + orl $0x100003c0,%eax + movl %eax,%dr7 + + popl %eax + + ret
Propchange: branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/i386trap.S ------------------------------------------------------------------------------ svn:eol-style = native
Added: branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/mb.S URL: http://svn.reactos.org/svn/reactos/branches/ros-amd64-bringup/reactos/boot/f... ============================================================================== --- branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/mb.S (added) +++ branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/mb.S [iso-8859-1] Wed Jul 23 21:18:44 2008 @@ -1,0 +1,79 @@ +/* + * FreeLoader + * Copyright (C) 1998-2002 Brian Palmer brianp@sginet.com + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + .text + .code16 + +#define ASM +#include <arch.h> +#include <multiboot.h> + + /* + * Here we assume the kernel is loaded at 1mb + * This boots the kernel + */ + .code32 + .globl _PageDirectoryStart + + .globl _startup_pagedirectory + .globl _lowmem_pagetable + .globl _kernel_pagetable + .globl _hyperspace_pagetable + .globl _apic_pagetable + .globl _kpcr_pagetable + .globl _kuser_pagetable + + .globl _PageDirectoryEnd + + // + // Boot information structure + // + +EXTERN(_reactos_memory_map_descriptor_size) + .long 0 + +EXTERN(_reactos_memory_map) + .rept (32 * /*sizeof(memory_map_t)*/24) + .byte 0 + .endr + +.bss +_PageDirectoryStart: +_startup_pagedirectory: + .fill 4096, 1, 0 + +_lowmem_pagetable: + .fill 4096, 1, 0 + +_kernel_pagetable: + .fill 2*4096, 1, 0 + +_hyperspace_pagetable: + .fill 4096, 1, 0 + +_apic_pagetable: + .fill 4096, 1, 0 + +_kpcr_pagetable: + .fill 4096, 1, 0 + +_kuser_pagetable: + .fill 4096, 1, 0 + +_PageDirectoryEnd:
Propchange: branches/ros-amd64-bringup/reactos/boot/freeldr/freeldr/arch/amd64/mb.S ------------------------------------------------------------------------------ svn:eol-style = native