Move some of the common header crap into header files.
authorhpa <hpa>
Fri, 26 Apr 2002 05:56:24 +0000 (05:56 +0000)
committerhpa <hpa>
Fri, 26 Apr 2002 05:56:24 +0000 (05:56 +0000)
Makefile
bios.inc [new file with mode: 0644]
isolinux.asm
kernel.inc [new file with mode: 0644]
ldlinux.asm
macros.inc [new file with mode: 0644]
pxelinux.asm
tracers.inc [new file with mode: 0644]

index b05b30a..1e124b7 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -176,6 +176,10 @@ spotless: local-clean dist local-spotless
        for csrc in $(CSRC) ; do $(CC) $(INCLUDE) -M $$csrc >> .depend ; done
        for nsrc in $(NASMSRC) ; do $(NASM) -DDEPEND $(NINCLUDE) -o `echo $$nsrc | sed -e 's/\.asm/\.bin/'` -M $$nsrc >> .depend ; done
 
+depend:
+       rm -f .depend
+       $(MAKE) .depend
+
 # Hook to add private Makefile targets for the maintainer.
 -include Makefile.private
 
diff --git a/bios.inc b/bios.inc
new file mode 100644 (file)
index 0000000..d85df55
--- /dev/null
+++ b/bios.inc
@@ -0,0 +1,38 @@
+;; $Id$
+;; -----------------------------------------------------------------------
+;;   
+;;   Copyright 1994-2002 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,
+;;   Bostom MA 02111-1307, USA; either version 2 of the License, or
+;;   (at your option) any later version; incorporated herein by reference.
+;;
+;; -----------------------------------------------------------------------
+
+;;
+;; bios.inc
+;; 
+;; Header file for the BIOS data structures etc.
+;;
+
+%ifndef _BIOS_INC
+%define _BIOS_INC
+
+               absolute 4*1Eh          ; In the interrupt table
+fdctab         equ $
+fdctab1                resw 1
+fdctab2                resw 1
+               absolute 0400h
+serial_base    resw 4                  ; Base addresses for 4 serial ports
+               absolute 0413h
+BIOS_fbm       resw 1                  ; Free Base Memory (kilobytes)
+               absolute 046Ch
+BIOS_timer     resw 1                  ; Timer ticks
+               absolute 0472h
+BIOS_magic     resw 1                  ; BIOS reset magic
+                absolute 0484h
+BIOS_vidrows    resb 1                 ; Number of screen rows
+
+%endif ; _BIOS_INC
index 0250a13..c19d28b 100644 (file)
 ; 
 ; ****************************************************************************
 
-; Note: The Makefile builds one version with DEBUG_MESSAGES automatically.
-; %define DEBUG_TRACERS                        ; Uncomment to get debugging tracers
-; %define DEBUG_MESSAGES               ; Uncomment to get debugging messages
-
-%ifdef DEBUG_TRACERS
-
-%macro TRACER  1
-       call debug_tracer
-       db %1
-%endmacro
-
-%else  ; DEBUG_TRACERS
-
-%macro TRACER  1
-%endmacro
-
-%endif ; DEBUG_TRACERS
+%include "macros.inc"
+%include "kernel.inc"
+%include "bios.inc"
+%include "tracers.inc"
 
 ;
 ; Some semi-configurable constants... change on your own risk.  Most are imposed
 ; by the kernel.
 ;
+my_id          equ isolinux_id
 max_cmd_len    equ 255                 ; Must be odd; 255 is the kernel limit
 FILENAME_MAX_LG2 equ 8                 ; log2(Max filename size Including final null)
 FILENAME_MAX   equ (1 << FILENAME_MAX_LG2)
@@ -59,78 +47,6 @@ SECTORSIZE   equ (1 << SECTORSIZE_LG2)
 %define        version_str     VERSION         ; Must be 4 characters long!
 %define date           DATE_STR        ; Defined from the Makefile
 %define        year            '2002'
-;
-; Debgging stuff
-;
-; %define debug 1                      ; Uncomment to enable debugging
-;
-; ID for SYSLINUX (reported to kernel)
-;
-syslinux_id    equ 033h                ; SYSLINUX (3) 3 = ISOLINUX
-
-;
-; Segments used by Linux
-;
-real_mode_seg  equ 5000h
-fake_setup_seg equ real_mode_seg+020h
-
-               struc real_mode_seg_t
-               resb 20h-($-$$)         ; org 20h
-kern_cmd_magic resw 1                  ; 0020 Magic # for command line
-kern_cmd_offset resw 1                 ; 0022 Offset for kernel command line
-               resb 497-($-$$)         ; org 497d
-bs_setupsecs   resb 1                  ; 01F1 Sectors for setup code (0 -> 4)
-bs_rootflags   resw 1                  ; 01F2 Root readonly flag
-bs_syssize     resw 1                  ; 01F4
-bs_swapdev     resw 1                  ; 01F6 Swap device (obsolete)
-bs_ramsize     resw 1                  ; 01F8 Ramdisk flags, formerly ramdisk size
-bs_vidmode     resw 1                  ; 01FA Video mode
-bs_rootdev     resw 1                  ; 01FC Root device
-bs_bootsign    resw 1                  ; 01FE Boot sector signature (0AA55h)
-su_jump                resb 1                  ; 0200 0EBh
-su_jump2       resb 1                  ; 0201 Size of following header
-su_header      resd 1                  ; 0202 New setup code: header
-su_version     resw 1                  ; 0206 See linux/arch/i386/boot/setup.S
-su_switch      resw 1                  ; 0208
-su_setupseg    resw 1                  ; 020A
-su_startsys    resw 1                  ; 020C
-su_kver                resw 1                  ; 020E Kernel version pointer
-su_loader      resb 1                  ; 0210 Loader ID
-su_loadflags   resb 1                  ; 0211 Load high flag
-su_movesize    resw 1                  ; 0212
-su_code32start resd 1                  ; 0214 Start of code loaded high
-su_ramdiskat   resd 1                  ; 0218 Start of initial ramdisk
-su_ramdisklen  equ $                   ; Length of initial ramdisk
-su_ramdisklen1 resw 1                  ; 021C
-su_ramdisklen2 resw 1                  ; 021E
-su_bsklugeoffs resw 1                  ; 0220
-su_bsklugeseg  resw 1                  ; 0222
-su_heapend     resw 1                  ; 0224
-su_pad1                resw 1                  ; 0226
-su_cmd_line_ptr        resd 1                  ; 0228
-su_ramdisk_max resd 1                  ; 022C
-               resb (9000h-12)-($-$$)  ; Were bootsect.S puts it...
-linux_stack    equ $                   ; 8FF4
-linux_fdctab   equ $
-               resb 9000h-($-$$)
-cmd_line_here  equ $                   ; 9000 Should be out of the way
-               endstruc
-
-;
-; Kernel command line signature
-;
-CMD_MAGIC      equ 0A33Fh              ; Command line magic
-
-;
-; Magic number of su_header field
-;
-HEADER_ID       equ 'HdrS'             ; HdrS (in littleendian hex)
-
-;
-; Flags for the su_loadflags field
-;
-LOAD_HIGH      equ 01h                 ; Large kernel, load high
-CAN_USE_HEAP    equ 80h                 ; Boot loader reports heap size
 
 ;
 ; The following structure is used for "virtual kernels"; i.e. LILO-style
@@ -164,8 +80,8 @@ vk_end:              equ $                   ; Should be <= vk_size
 ;
 ; Segment assignments in the bottom 640K
 ; 0000h - main code/data segment (and BIOS segment)
-; 5000h - real_mode_seg
 ;
+real_mode_seg  equ 5000h
 vk_seg          equ 4000h              ; Virtual kernels
 xfer_buf_seg   equ 3000h               ; Bounce buffer for I/O to high mem
 comboot_seg    equ 2000h               ; COMBOOT image loading zone
@@ -184,88 +100,10 @@ file_left resd 1                  ; Number of sectors left
 %endif
 %endif
 
-;
-; For our convenience: define macros for jump-over-unconditinal jumps
-;
-%macro jmpz    1
-       jnz %%skip
-       jmp %1
-%%skip:
-%endmacro
-
-%macro jmpnz   1
-       jz %%skip
-       jmp %1
-%%skip:
-%endmacro
-
-%macro jmpe    1
-       jne %%skip
-       jmp %1
-%%skip:
-%endmacro
-
-%macro jmpne   1
-       je %%skip
-       jmp %1
-%%skip:
-%endmacro
-
-%macro jmpc    1
-       jnc %%skip
-       jmp %1
-%%skip:
-%endmacro
-
-%macro jmpnc   1
-       jc %%skip
-       jmp %1
-%%skip:
-%endmacro
-
-%macro jmpb    1
-       jnb %%skip
-       jmp %1
-%%skip:
-%endmacro
-
-%macro jmpnb   1
-       jb %%skip
-       jmp %1
-%%skip:
-%endmacro
-
-;
-; Macros similar to res[bwd], but which works in the code segment (after
-; section .text)
-;
-%macro zb      1
-       times %1 db 0
-%endmacro
-
-%macro zw      1
-       times %1 dw 0
-%endmacro
-
-%macro zd      1
-       times %1 dd 0
-%endmacro
-
 ; ---------------------------------------------------------------------------
-;   BEGIN THE BIOS/CODE/DATA SEGMENT
+;   BEGIN CODE
 ; ---------------------------------------------------------------------------
 
-               absolute 0400h
-serial_base    resw 4                  ; Base addresses for 4 serial ports
-               absolute 0413h
-BIOS_fbm       resw 1                  ; Free Base Memory (kilobytes)
-               absolute 046Ch
-BIOS_timer     resw 1                  ; Timer ticks
-               absolute 0472h
-BIOS_magic     resw 1                  ; BIOS reset magic
-                absolute 0484h
-BIOS_vidrows    resb 1                 ; Number of screen rows
-
 ;
 ; Memory below this point is reserved for the BIOS and the MBR
 ;
@@ -1979,7 +1817,7 @@ cmdline_end:
 ; and that we are clueful
 ;
 new_kernel:
-               mov byte [es:su_loader],syslinux_id     ; Show some ID
+               mov byte [es:su_loader],my_id   ; Show some ID
                movzx ax,byte [es:bs_setupsecs] ; Variable # of setup sectors
                mov [SetupSecs],ax
 ;
diff --git a/kernel.inc b/kernel.inc
new file mode 100644 (file)
index 0000000..0756c6a
--- /dev/null
@@ -0,0 +1,92 @@
+;; $Id$
+;; -----------------------------------------------------------------------
+;;   
+;;   Copyright 1994-2002 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,
+;;   Bostom MA 02111-1307, USA; either version 2 of the License, or
+;;   (at your option) any later version; incorporated herein by reference.
+;;
+;; -----------------------------------------------------------------------
+
+;;
+;; kernel.inc
+;; 
+;; Header file for the kernel interface definitions
+;;
+
+%ifndef _KERNEL_INC
+%define _KERNEL_INC
+
+;;
+;; Structure of the real_mode_seg
+;;
+
+               struc real_mode_seg_t
+               resb 20h-($-$$)         ; org 20h
+kern_cmd_magic resw 1                  ; 0020 Magic # for command line
+kern_cmd_offset resw 1                 ; 0022 Offset for kernel command line
+               resb 497-($-$$)         ; org 497d
+bs_setupsecs   resb 1                  ; 01F1 Sectors for setup code (0 -> 4)
+bs_rootflags   resw 1                  ; 01F2 Root readonly flag
+bs_syssize     resw 1                  ; 01F4
+bs_swapdev     resw 1                  ; 01F6 Swap device (obsolete)
+bs_ramsize     resw 1                  ; 01F8 Ramdisk flags, formerly ramdisk size
+bs_vidmode     resw 1                  ; 01FA Video mode
+bs_rootdev     resw 1                  ; 01FC Root device
+bs_bootsign    resw 1                  ; 01FE Boot sector signature (0AA55h)
+su_jump                resb 1                  ; 0200 0EBh
+su_jump2       resb 1                  ; 0201 Size of following header
+su_header      resd 1                  ; 0202 New setup code: header
+su_version     resw 1                  ; 0206 See linux/arch/i386/boot/setup.S
+su_switch      resw 1                  ; 0208
+su_setupseg    resw 1                  ; 020A
+su_startsys    resw 1                  ; 020C
+su_kver                resw 1                  ; 020E Kernel version pointer
+su_loader      resb 1                  ; 0210 Loader ID
+su_loadflags   resb 1                  ; 0211 Load high flag
+su_movesize    resw 1                  ; 0212
+su_code32start resd 1                  ; 0214 Start of code loaded high
+su_ramdiskat   resd 1                  ; 0218 Start of initial ramdisk
+su_ramdisklen  equ $                   ; Length of initial ramdisk
+su_ramdisklen1 resw 1                  ; 021C
+su_ramdisklen2 resw 1                  ; 021E
+su_bsklugeoffs resw 1                  ; 0220
+su_bsklugeseg  resw 1                  ; 0222
+su_heapend     resw 1                  ; 0224
+su_pad1                resw 1                  ; 0226
+su_cmd_line_ptr        resd 1                  ; 0228
+su_ramdisk_max resd 1                  ; 022C
+               resb (9000h-12)-($-$$)  ; Were bootsect.S puts it...
+linux_stack    equ $                   ; 8FF4
+linux_fdctab   equ $
+               resb 9000h-($-$$)
+cmd_line_here  equ $                   ; 9000 Should be out of the way
+               endstruc
+
+;
+; Kernel command line signature
+;
+CMD_MAGIC      equ 0A33Fh              ; Command line magic
+
+;
+; Magic number of su_header field
+;
+HEADER_ID       equ 'HdrS'             ; HdrS (in littleendian hex)
+
+;
+; Flags for the su_loadflags field
+;
+LOAD_HIGH      equ 01h                 ; Large kernel, load high
+CAN_USE_HEAP    equ 80h                 ; Boot loader reports heap size
+
+;
+; ID codes for various modules
+;
+syslinux_id    equ 031h                ; 3 = SYSLINUX family; 1 = SYSLINUX
+pxelinux_id    equ 032h                ; 3 = SYSLINUX family; 2 = PXELINUX
+isolinux_id    equ 033h                ; 3 = SYSLINUX family; 3 = PXELINUX
+
+%endif ; _KERNEL_INC
index 8999ed5..74e1d75 100644 (file)
 ; 
 ; ****************************************************************************
 
+%include "macros.inc"
+%include "kernel.inc"
+%include "bios.inc"
+%include "tracers.inc"
+
 ;
 ; Some semi-configurable constants... change on your own risk.  Most are imposed
 ; by the kernel.
 ;
+my_id          equ syslinux_id
 max_cmd_len    equ 255                 ; Must be odd; 255 is the kernel limit
 retry_count    equ 6                   ; How patient are we with the disk?
 HIGHMEM_MAX    equ 037FFFFFFh          ; DEFAULT highest address for an initrd
@@ -41,81 +47,6 @@ BAUD_DIVISOR equ 115200              ; Serial port parameter
 %define        version_str     VERSION         ; Must be 4 characters long!
 %define date           DATE_STR        ; Defined from the Makefile
 %define        year            '2002'
-;
-; Debgging stuff
-;
-; %define debug 1                      ; Uncomment to enable debugging
-;
-; ID for SYSLINUX (reported to kernel)
-;
-syslinux_id    equ 031h                ; SYSLINUX (3) version 1.x (1)
-;
-; Segments used by Linux
-;
-; Note: the real_mode_seg is supposed to be 9000h, but some device drivers
-; hog some of high memory.  Therefore, we load it at 7000:0000h and copy
-; it before starting the Linux kernel.
-;
-real_mode_seg  equ 7000h
-fake_setup_seg equ real_mode_seg+020h
-
-               struc real_mode_seg_t
-               resb 20h-($-$$)         ; org 20h
-kern_cmd_magic resw 1                  ; 0020 Magic # for command line
-kern_cmd_offset resw 1                 ; 0022 Offset for kernel command line
-               resb 497-($-$$)         ; org 497d
-bs_setupsecs   resb 1                  ; 01F1 Sectors for setup code (0 -> 4)
-bs_rootflags   resw 1                  ; 01F2 Root readonly flag
-bs_syssize     resw 1                  ; 01F4
-bs_swapdev     resw 1                  ; 01F6 Swap device (obsolete)
-bs_ramsize     resw 1                  ; 01F8 Ramdisk flags, formerly ramdisk size
-bs_vidmode     resw 1                  ; 01FA Video mode
-bs_rootdev     resw 1                  ; 01FC Root device
-bs_bootsign    resw 1                  ; 01FE Boot sector signature (0AA55h)
-su_jump                resb 1                  ; 0200 0EBh
-su_jump2       resb 1                  ; 0201 Size of following header
-su_header      resd 1                  ; 0202 New setup code: header
-su_version     resw 1                  ; 0206 See linux/arch/i386/boot/setup.S
-su_switch      resw 1                  ; 0208
-su_setupseg    resw 1                  ; 020A
-su_startsys    resw 1                  ; 020C
-su_kver                resw 1                  ; 020E Kernel version pointer
-su_loader      resb 1                  ; 0210 Loader ID
-su_loadflags   resb 1                  ; 0211 Load high flag
-su_movesize    resw 1                  ; 0212
-su_code32start resd 1                  ; 0214 Start of code loaded high
-su_ramdiskat   resd 1                  ; 0218 Start of initial ramdisk
-su_ramdisklen  equ $                   ; Length of initial ramdisk
-su_ramdisklen1 resw 1                  ; 021C
-su_ramdisklen2 resw 1                  ; 021E
-su_bsklugeoffs resw 1                  ; 0220
-su_bsklugeseg  resw 1                  ; 0222
-su_heapend     resw 1                  ; 0224
-su_pad1                resw 1                  ; 0226
-su_cmd_line_ptr        resd 1                  ; 0228
-su_ramdisk_max resd 1                  ; 022C
-               resb (9000h-12)-($-$$)  ; The setup is up to 32K long
-linux_stack    equ $                   ; 8FF4
-linux_fdctab   equ $
-               resb 9000h-($-$$)
-cmd_line_here  equ $                   ; 9000 Should be out of the way
-               endstruc
-
-;
-; Kernel command line signature
-;
-CMD_MAGIC      equ 0A33Fh              ; Command line magic
-
-;
-; Magic number of su_header field
-;
-HEADER_ID       equ 'HdrS'             ; HdrS (in littleendian hex)
-
-;
-; Flags for the su_loadflags field
-;
-LOAD_HIGH      equ 01h                 ; Large kernel, load high
-CAN_USE_HEAP    equ 80h                 ; Boot loader reports heap size
 
 ;
 ; The following structure is used for "virtual kernels"; i.e. LILO-style
@@ -152,93 +83,16 @@ vk_end:            equ $                   ; Should be <= vk_size
 ; which load a driver into low RAM (evil!!)
 ;
 ; 0000h - main code/data segment (and BIOS segment)
-; 7000h - real_mode_seg
 ;
+real_mode_seg  equ 7000h
 fat_seg                equ 5000h               ; 128K area for FAT (2x64K)
 vk_seg          equ 4000h              ; Virtual kernels
 xfer_buf_seg   equ 3000h               ; Bounce buffer for I/O to high mem
 comboot_seg    equ 2000h               ; COMBOOT image loading zone
 
-;
-; For our convenience: define macros for jump-over-unconditinal jumps
-;
-%macro jmpz    1
-       jnz %%skip
-       jmp %1
-%%skip:
-%endmacro
-
-%macro jmpnz   1
-       jz %%skip
-       jmp %1
-%%skip:
-%endmacro
-
-%macro jmpe    1
-       jne %%skip
-       jmp %1
-%%skip:
-%endmacro
-
-%macro jmpne   1
-       je %%skip
-       jmp %1
-%%skip:
-%endmacro
-
-%macro jmpc    1
-       jnc %%skip
-       jmp %1
-%%skip:
-%endmacro
-
-%macro jmpnc   1
-       jc %%skip
-       jmp %1
-%%skip:
-%endmacro
-
-%macro jmpb    1
-       jnb %%skip
-       jmp %1
-%%skip:
-%endmacro
-
-%macro jmpnb   1
-       jb %%skip
-       jmp %1
-%%skip:
-%endmacro
-
-;
-; Macros similar to res[bwd], but which works in the code segment (after
-; section .text)
-;
-%macro zb      1
-       times %1 db 0
-%endmacro
-
-%macro zw      1
-       times %1 dw 0
-%endmacro
-
-%macro zd      1
-       times %1 dd 0
-%endmacro
-
 ; ---------------------------------------------------------------------------
-;   BEGIN THE BIOS/CODE/DATA SEGMENT
+;   BEGIN CODE
 ; ---------------------------------------------------------------------------
-               absolute 4*1Eh          ; In the interrupt table
-fdctab         equ $
-fdctab1                resw 1
-fdctab2                resw 1
-
-               absolute 0400h
-serial_base    resw 4                  ; Base addresses for 4 serial ports
-
-                absolute 0484h
-BIOS_vidrows    resb 1                 ; Number of screen rows
 
 ;
 ; Memory below this point is reserved for the BIOS and the MBR
@@ -2036,7 +1890,7 @@ cmdline_end:
 ; and that we are clueful
 ;
 new_kernel:
-               mov byte [es:su_loader],syslinux_id     ; Show some ID
+               mov byte [es:su_loader],my_id   ; Show some ID
                movzx ax,byte [es:bs_setupsecs] ; Variable # of setup sectors
                mov [SetupSecs],ax
 ;
diff --git a/macros.inc b/macros.inc
new file mode 100644 (file)
index 0000000..5a02957
--- /dev/null
@@ -0,0 +1,98 @@
+;; $Id$
+;; -----------------------------------------------------------------------
+;;   
+;;   Copyright 1994-2002 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,
+;;   Bostom MA 02111-1307, USA; either version 2 of the License, or
+;;   (at your option) any later version; incorporated herein by reference.
+;;
+;; -----------------------------------------------------------------------
+
+;;
+;; macros.inc
+;; 
+;; Convenient macros
+;;
+
+%ifndef _MACROS_INC
+%define _MACROS_INC
+
+;
+; For our convenience: define macros for jump-over-unconditinal jumps
+;
+%macro jmpz    1
+       jnz %%skip
+       jmp %1
+%%skip:
+%endmacro
+
+%macro jmpnz   1
+       jz %%skip
+       jmp %1
+%%skip:
+%endmacro
+
+%macro jmpe    1
+       jne %%skip
+       jmp %1
+%%skip:
+%endmacro
+
+%macro jmpne   1
+       je %%skip
+       jmp %1
+%%skip:
+%endmacro
+
+%macro jmpc    1
+       jnc %%skip
+       jmp %1
+%%skip:
+%endmacro
+
+%macro jmpnc   1
+       jc %%skip
+       jmp %1
+%%skip:
+%endmacro
+
+%macro jmpb    1
+       jnb %%skip
+       jmp %1
+%%skip:
+%endmacro
+
+%macro jmpnb   1
+       jb %%skip
+       jmp %1
+%%skip:
+%endmacro
+
+;
+; Macros similar to res[bwd], but which works in the code segment (after
+; section .text)
+;
+%macro zb      1
+       times %1 db 0
+%endmacro
+
+%macro zw      1
+       times %1 dw 0
+%endmacro
+
+%macro zd      1
+       times %1 dd 0
+%endmacro
+
+;
+; Macros for network byte order of constants
+;
+%define htons(x)  ( ( ((x) & 0FFh) << 8 ) + ( ((x) & 0FF00h) >> 8 ) )
+%define ntohs(x) htons(x)
+%define htonl(x)  ( ( ((x) & 0FFh) << 24) + ( ((x) & 0FF00h) << 8 ) + ( ((x) & 0FF0000h) >> 8 ) + ( ((x) & 0FF000000h) >> 24) )
+%define ntohl(x) htonl(x)
+
+%endif ; _MACROS_INC
index c68e0a4..c72c8ba 100644 (file)
 ; 
 ; ****************************************************************************
 
-
+%include "macros.inc"
+%include "kernel.inc"
+%include "bios.inc"
+%include "tracers.inc"
 %include "pxe.inc"
 
 ;
-; Macros for byte order of constants
-;
-%define htons(x)  ( ( ((x) & 0FFh) << 8 ) + ( ((x) & 0FF00h) >> 8 ) )
-%define ntohs(x) htons(x)
-%define htonl(x)  ( ( ((x) & 0FFh) << 24) + ( ((x) & 0FF00h) << 8 ) + ( ((x) & 0FF0000h) >> 8 ) + ( ((x) & 0FF000000h) >> 24) )
-%define ntohl(x) htonl(x)
-
-;
 ; Some semi-configurable constants... change on your own risk.  Most are imposed
 ; by the kernel.
 ;
+my_id          equ pxelinux_id
 max_cmd_len    equ 255                 ; Must be odd; 255 is the kernel limit
 FILENAME_MAX_LG2 equ 6                 ; log2(Max filename size Including final null)
 FILENAME_MAX   equ (1 << FILENAME_MAX_LG2)
@@ -65,81 +61,6 @@ TFTP_OACK    equ htons(6)            ; OACK packet
 %define        version_str     VERSION         ; Must be 4 characters long!
 %define date           DATE_STR        ; Defined from the Makefile
 %define        year            '2002'
-;
-; Debgging stuff
-;
-; %define debug 1                      ; Uncomment to enable debugging
-;
-; ID for SYSLINUX (reported to kernel)
-;
-syslinux_id    equ 032h                ; SYSLINUX (3) 2 = PXELINUX
-;
-; Segments used by Linux
-;
-; Note: the real_mode_seg is supposed to be 9000h, but PXE uses that
-; memory.  Therefore, we load it at 5000:0000h and copy it before starting
-; the Linux kernel.
-;
-real_mode_seg  equ 5000h
-fake_setup_seg equ real_mode_seg+020h
-
-               struc real_mode_seg_t
-               resb 20h-($-$$)         ; org 20h
-kern_cmd_magic resw 1                  ; 0020 Magic # for command line
-kern_cmd_offset resw 1                 ; 0022 Offset for kernel command line
-               resb 497-($-$$)         ; org 497d
-bs_setupsecs   resb 1                  ; 01F1 Sectors for setup code (0 -> 4)
-bs_rootflags   resw 1                  ; 01F2 Root readonly flag
-bs_syssize     resw 1                  ; 01F4
-bs_swapdev     resw 1                  ; 01F6 Swap device (obsolete)
-bs_ramsize     resw 1                  ; 01F8 Ramdisk flags, formerly ramdisk size
-bs_vidmode     resw 1                  ; 01FA Video mode
-bs_rootdev     resw 1                  ; 01FC Root device
-bs_bootsign    resw 1                  ; 01FE Boot sector signature (0AA55h)
-su_jump                resb 1                  ; 0200 0EBh
-su_jump2       resb 1                  ; 0201 Size of following header
-su_header      resd 1                  ; 0202 New setup code: header
-su_version     resw 1                  ; 0206 See linux/arch/i386/boot/setup.S
-su_switch      resw 1                  ; 0208
-su_setupseg    resw 1                  ; 020A
-su_startsys    resw 1                  ; 020C
-su_kver                resw 1                  ; 020E Kernel version pointer
-su_loader      resb 1                  ; 0210 Loader ID
-su_loadflags   resb 1                  ; 0211 Load high flag
-su_movesize    resw 1                  ; 0212
-su_code32start resd 1                  ; 0214 Start of code loaded high
-su_ramdiskat   resd 1                  ; 0218 Start of initial ramdisk
-su_ramdisklen  equ $                   ; Length of initial ramdisk
-su_ramdisklen1 resw 1                  ; 021C
-su_ramdisklen2 resw 1                  ; 021E
-su_bsklugeoffs resw 1                  ; 0220
-su_bsklugeseg  resw 1                  ; 0222
-su_heapend     resw 1                  ; 0224
-su_pad1                resw 1                  ; 0226
-su_cmd_line_ptr        resd 1                  ; 0228
-su_ramdisk_max resd 1                  ; 022C
-               resb (9000h-12)-($-$$)  ; Were bootsect.S puts it...
-linux_stack    equ $                   ; 8FF4
-linux_fdctab   equ $
-               resb 9000h-($-$$)
-cmd_line_here  equ $                   ; 9000 Should be out of the way
-               endstruc
-
-;
-; Kernel command line signature
-;
-CMD_MAGIC      equ 0A33Fh              ; Command line magic
-
-;
-; Magic number of su_header field
-;
-HEADER_ID       equ 'HdrS'             ; HdrS (in littleendian hex)
-
-;
-; Flags for the su_loadflags field
-;
-LOAD_HIGH      equ 01h                 ; Large kernel, load high
-CAN_USE_HEAP    equ 80h                 ; Boot loader reports heap size
 
 ;
 ; The following structure is used for "virtual kernels"; i.e. LILO-style
@@ -175,8 +96,8 @@ vk_end:              equ $                   ; Should be <= vk_size
 ;
 ; Segment assignments in the bottom 640K
 ; 0000h - main code/data segment (and BIOS segment)
-; 5000h - real_mode_seg
 ;
+real_mode_seg  equ 5000h
 vk_seg          equ 4000h              ; Virtual kernels
 xfer_buf_seg   equ 3000h               ; Bounce buffer for I/O to high mem
 comboot_seg    equ 2000h               ; COMBOOT image loading zone
@@ -224,88 +145,10 @@ tftp_filesize     resd 1                  ; Total file size
 %endif
 %endif
 
-;
-; For our convenience: define macros for jump-over-unconditinal jumps
-;
-%macro jmpz    1
-       jnz %%skip
-       jmp %1
-%%skip:
-%endmacro
-
-%macro jmpnz   1
-       jz %%skip
-       jmp %1
-%%skip:
-%endmacro
-
-%macro jmpe    1
-       jne %%skip
-       jmp %1
-%%skip:
-%endmacro
-
-%macro jmpne   1
-       je %%skip
-       jmp %1
-%%skip:
-%endmacro
-
-%macro jmpc    1
-       jnc %%skip
-       jmp %1
-%%skip:
-%endmacro
-
-%macro jmpnc   1
-       jc %%skip
-       jmp %1
-%%skip:
-%endmacro
-
-%macro jmpb    1
-       jnb %%skip
-       jmp %1
-%%skip:
-%endmacro
-
-%macro jmpnb   1
-       jb %%skip
-       jmp %1
-%%skip:
-%endmacro
-
-;
-; Macros similar to res[bwd], but which works in the code segment (after
-; section .text)
-;
-%macro zb      1
-       times %1 db 0
-%endmacro
-
-%macro zw      1
-       times %1 dw 0
-%endmacro
-
-%macro zd      1
-       times %1 dd 0
-%endmacro
-
 ; ---------------------------------------------------------------------------
-;   BEGIN THE BIOS/CODE/DATA SEGMENT
+;   BEGIN CODE
 ; ---------------------------------------------------------------------------
 
-               absolute 0400h
-serial_base    resw 4                  ; Base addresses for 4 serial ports
-               absolute 0413h
-BIOS_fbm       resw 1                  ; Free Base Memory (kilobytes)
-               absolute 046Ch
-BIOS_timer     resw 1                  ; Timer ticks
-               absolute 0472h
-BIOS_magic     resw 1                  ; BIOS reset magic
-                absolute 0484h
-BIOS_vidrows    resb 1                 ; Number of screen rows
-
 ;
 ; Memory below this point is reserved for the BIOS and the MBR
 ;
@@ -1856,7 +1699,7 @@ cmdline_end:
 ; and that we are clueful
 ;
 new_kernel:
-               mov byte [es:su_loader],syslinux_id     ; Show some ID
+               mov byte [es:su_loader],my_id   ; Show some ID
                movzx ax,byte [es:bs_setupsecs] ; Variable # of setup sectors
                mov [SetupSecs],ax
 ;
diff --git a/tracers.inc b/tracers.inc
new file mode 100644 (file)
index 0000000..e0dbe86
--- /dev/null
@@ -0,0 +1,41 @@
+;; $Id$
+;; -----------------------------------------------------------------------
+;;   
+;;   Copyright 1994-2002 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,
+;;   Bostom MA 02111-1307, USA; either version 2 of the License, or
+;;   (at your option) any later version; incorporated herein by reference.
+;;
+;; -----------------------------------------------------------------------
+
+;;
+;; tracers.inc
+;; 
+;; Debugging tracers
+;;
+
+%ifndef _TRACERS_INC
+%define _TRACERS_INC
+
+; Note: The Makefile builds one version with DEBUG_MESSAGES automatically.
+; %define DEBUG_TRACERS                        ; Uncomment to get debugging tracers
+; %define DEBUG_MESSAGES               ; Uncomment to get debugging messages
+
+%ifdef DEBUG_TRACERS
+
+%macro TRACER  1
+       call debug_tracer
+       db %1
+%endmacro
+
+%else  ; DEBUG_TRACERS
+
+%macro TRACER  1
+%endmacro
+
+%endif ; DEBUG_TRACERS
+
+%endif ; _TRACERS_INC