and restoring it. The former option left crap on the stack.
-; $Id$
; -----------------------------------------------------------------------
;
-; Copyright 2005 H. Peter Anvin - All Rights Reserved
+; Copyright 2005-2006 H. Peter Anvin - All Rights Reserved
;
; 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
mov ax,cs ; Restore CS = DS = ES
mov ds,ax
mov es,ax
-%if IS_SYSLINUX || IS_EXTLINUX
- mov ss,ax ; Just in case...
- mov sp,StackBuf-2*3 ; Reset stack
-%elif IS_PXELINUX
- lss esp,[BaseStack]
-%elif IS_ISOLINUX
- lss sp,[StackPtr]
-%else
- NEED TO KNOW HOW TO RESET STACK
-%endif
+ RESET_STACK
sti
call cwritestr ; Expects SI -> error msg
section .earlybss
alignb 2
EntryPoint resd 1 ; CS:IP for shuffle_and_boot
-SavedSSSP resd 1 ; Saved real mode SS:SP
A20Test resw 1 ; Counter for testing status of A20
A20Tries resb 1 ; Times until giving up on A20
cli
mov ax,cs
mov ds,ax
- mov [SavedSSSP],sp
- mov [SavedSSSP+2],ss
+ mov [RealModeSSSP],sp
+ mov [RealModeSSSP+2],ss
cld
call a20_test
jnz .a20ok
mov es,ax
mov fs,ax
mov gs,ax
- lss sp,[SavedSSSP] ; Restore stack
+ lss sp,[RealModeSSSP] ; Restore stack
jmp bx ; Go to whereever we need to go...
com32_done:
com32_syscall:
cld
- movzx edi,word [word SavedSSSP]
- movzx ebx,word [word SavedSSSP+2]
+ movzx edi,word [word RealModeSSSP]
+ movzx ebx,word [word RealModeSSSP+2]
sub edi,54 ; Allocate 54 bytes
- mov [word SavedSSSP],di
+ mov [word RealModeSSSP],di
shl ebx,4
add edi,ebx ; Create linear address
; real-mode stack, plus the 10 additional bytes used
; by the target address (see above.)
com32_sys_resume:
- movzx esi,word [word SavedSSSP]
- movzx eax,word [word SavedSSSP+2]
+ movzx esi,word [word RealModeSSSP]
+ movzx eax,word [word RealModeSSSP+2]
mov edi,[esp+12*4] ; Dest regs
shl eax,4
add esi,eax ; Create linear address
mov cl,11 ; 44 bytes
rep movsd ; Copy register block
- add dword [word SavedSSSP],54 ; Remove from stack
+ add dword [word RealModeSSSP],54 ; Remove from stack
popad
popfd
section .bss
alignb 4
+RealModeSSSP resd 1 ; Real-mode SS:SP
PMESP resd 1 ; Protected-mode ESP
Com32SysSP resw 1 ; SP saved during COM32 syscall
call getfssec
; And invoke the program...
- mov [SavedSSSP],sp
- mov [SavedSSSP+2],ss ; Save away SS:SP
-
mov ax,es
mov ds,ax
mov ss,ax
xor dx,dx
mov ds,dx
mov es,dx
- lss sp,[SavedSSSP]
+ RESET_STACK
sti
cld
call adjust_screen ; The COMBOOT program might have changed the screen
; -*- fundamental -*- (asm-mode sucks)
-; $Id$
; ****************************************************************************
;
; extlinux.asm
;
; A program to boot Linux kernels off an ext2/ext3 filesystem.
;
-; Copyright (C) 1994-2005 H. Peter Anvin
+; Copyright (C) 1994-2006 H. Peter Anvin
;
; 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
; ****************************************************************************
%define IS_EXTLINUX 1
-%include "macros.inc"
-%include "config.inc"
-%include "kernel.inc"
-%include "bios.inc"
-%include "tracers.inc"
-%include "layout.inc"
-
+%include "head.inc"
%include "ext2_fs.inc"
;
; -*- fundamental -*- (asm-mode sucks)
-; $Id$
; ****************************************************************************
;
; isolinux.asm
; available. It is based on the SYSLINUX boot loader for MS-DOS
; floppies.
;
-; Copyright (C) 1994-2005 H. Peter Anvin
+; Copyright (C) 1994-2006 H. Peter Anvin
;
; 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
; ****************************************************************************
%define IS_ISOLINUX 1
-%include "macros.inc"
-%include "config.inc"
-%include "kernel.inc"
-%include "bios.inc"
-%include "tracers.inc"
-%include "layout.inc"
+%include "head.inc"
;
; Some semi-configurable constants... change on your own risk.
%ifndef IS_MDSLINUX
%define IS_SYSLINUX 1
%endif
-%include "macros.inc"
-%include "config.inc"
-%include "kernel.inc"
-%include "bios.inc"
-%include "tracers.inc"
-%include "layout.inc"
+%include "head.inc"
+
;
; Some semi-configurable constants... change on your own risk.
;
; -*- fundamental -*- (asm-mode sucks)
-; $Id$
; ****************************************************************************
;
; pxelinux.asm
; network booting API. It is based on the SYSLINUX boot loader for
; MS-DOS floppies.
;
-; Copyright (C) 1994-2005 H. Peter Anvin
+; Copyright (C) 1994-2006 H. Peter Anvin
;
; 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
; ****************************************************************************
%define IS_PXELINUX 1
-%include "macros.inc"
-%include "config.inc"
-%include "kernel.inc"
-%include "bios.inc"
-%include "tracers.inc"
+%include "head.inc"
%include "pxe.inc"
-%include "layout.inc"
;
; Some semi-configurable constants... change on your own risk.
jmp .call_loop
.call_done:
-;
-; This isn't necessary anymore; we can use the memory area previously
-; used by the PXE stack indefinitely, and the chainload code sets up
-; a new stack independently. Leave the source code in here for now,
-; but expect to rip it out soonish.
-;
-%if 0 ; USE_PXE_PROVIDED_STACK
- ; We need to switch to our local stack here...
- pusha
- pushf
- push gs
-
- mov si,sp
- mov ax,ss
- mov gs,ax
- sub ax,[BaseStack+4] ; Are we using the base stack
- je .is_base_stack ; (as opposed to the COMBOOT stack)?
-
- lgs si,[SavedSSSP] ; COMBOOT stack
-.is_base_stack:
-
- mov cx,[InitStack]
- mov di,StackBuf
- mov [BaseStack],di
- mov [BaseStack+4],es
- sub cx,si
- sub di,cx
- mov [SavedSSSP],di ; New SP
- mov [SavedSSSP+2],es
- gs rep movsb
-
- and ax,ax ; Remember which stack
- jne .combootstack
-
- ; Update the base stack pointer since it's in use
- lss sp,[SavedSSSP]
-
-.combootstack:
- pop gs
- popf
- popa
-%endif
mov bx,0FF00h
mov dx,[RealBaseMem]
--- /dev/null
+; -----------------------------------------------------------------------
+;
+; Copyright 2005-2006 H. Peter Anvin - All Rights Reserved
+;
+; 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, Inc., 53 Temple Place Ste 330,
+; Boston MA 02111-1307, USA; either version 2 of the License, or
+; (at your option) any later version; incorporated herein by reference.
+;
+; -----------------------------------------------------------------------
+
+;
+; stack.inc
+;
+; How to reset the stack pointer
+;
+
+%ifndef _STACK_INC
+%define _STACK_INC
+
+;
+; This macro resets the stack pointer. It assumes CS == DS.
+;
+%macro RESET_STACK 0
+%if IS_SYSLINUX || IS_EXTLINUX
+ mov ss,ax ; Just in case...
+ mov sp,StackBuf-2*3 ; Reset stack
+%elif IS_PXELINUX
+ lss esp,[BaseStack]
+%elif IS_ISOLINUX
+ lss sp,[StackPtr]
+%else
+ NEED TO KNOW HOW TO RESET STACK
+%endif
+%endmacro
+
+%endif ; _STACK_INC