diff options
-rw-r--r-- | Makefile | 25 | ||||
-rw-r--r-- | bcopy32.inc | 88 | ||||
-rw-r--r-- | cpuinit.inc | 14 | ||||
-rw-r--r-- | extlinux.asm | 8 | ||||
-rw-r--r-- | font.inc | 2 | ||||
-rw-r--r-- | isolinux.asm | 8 | ||||
-rw-r--r-- | ldlinux.asm | 9 | ||||
-rw-r--r-- | pxelinux.asm | 17 |
8 files changed, 62 insertions, 109 deletions
@@ -118,31 +118,32 @@ kwdhash.gen: keywords genhash.pl ldlinux.bin: ldlinux.asm kwdhash.gen version.gen $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \ - -l ldlinux.lst -o ldlinux.bin ldlinux.asm + -DMAP=ldlinux.map -l ldlinux.lst -o ldlinux.bin ldlinux.asm pxelinux.bin: pxelinux.asm kwdhash.gen version.gen $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \ - -l pxelinux.lst -o pxelinux.bin pxelinux.asm + -DMAP=pxelinux.map -l pxelinux.lst -o pxelinux.bin pxelinux.asm isolinux.bin: isolinux.asm kwdhash.gen version.gen checksumiso.pl $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \ - -l isolinux.lst -o isolinux.bin isolinux.asm + -DMAP=isolinux.map -l isolinux.lst -o isolinux.bin isolinux.asm $(PERL) checksumiso.pl isolinux.bin -extlinux.bin: extlinux.asm kwdhash.gen version.gen - $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \ - -l extlinux.lst -o extlinux.bin extlinux.asm - -pxelinux.0: pxelinux.bin - cp pxelinux.bin pxelinux.0 - # Special verbose version of isolinux.bin isolinux-debug.bin: isolinux.asm kwdhash.gen version.gen checksumiso.pl $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \ -DDEBUG_MESSAGES \ - -l isolinux-debug.lst -o isolinux-debug.bin isolinux.asm + -DMAP=isolinux-debug.map -l isolinux-debug.lst \ + -o isolinux-debug.bin isolinux.asm $(PERL) checksumiso.pl $@ +extlinux.bin: extlinux.asm kwdhash.gen version.gen + $(NASM) -f bin -DDATE_STR="'$(DATE)'" -DHEXDATE="$(HEXDATE)" \ + -DMAP=extlinux.map -l extlinux.lst -o extlinux.bin extlinux.asm + +pxelinux.0: pxelinux.bin + cp pxelinux.bin pxelinux.0 + ldlinux.bss: ldlinux.bin dd if=$< of=$@ bs=512 count=1 @@ -209,7 +210,7 @@ install-all: install install-lib local-tidy: rm -f *.o *_bin.c stupid.* patch.offset - rm -f *.lst + rm -f *.lst *.map rm -f $(OBSOLETE) tidy: local-tidy diff --git a/bcopy32.inc b/bcopy32.inc index 7b707801..5e3fda2b 100644 --- a/bcopy32.inc +++ b/bcopy32.inc @@ -27,11 +27,11 @@ ; segments, but this stuff is painful enough as it is without having to rely ; on everything happening "as it ought to." ; -; IMPORTANT: This code must be capable of operating when copied to the -; trackbuf area (1000h). The routine bcopy_over_self handles this mode -; of operation, including any necessary adjustments. +; NOTE: this code is relocated into low memory, just after the .earlybss +; segment, in order to support to "bcopy over self" operation. ; - section .text + + section .bcopy32 align 8 __bcopy_start: @@ -39,7 +39,7 @@ __bcopy_start: ; contiguous with the rest of the bcopy stuff bcopy_gdt: dw bcopy_gdt_size-1 ; Null descriptor - contains GDT -.adj1: dd bcopy_gdt ; pointer for LGDT instruction + dd bcopy_gdt ; pointer for LGDT instruction dw 0 dd 0000ffffh ; Code segment, use16, readable, dd 00009b00h ; present, dpl 0, cover 64K @@ -81,11 +81,11 @@ bcopy: push eax cli call enable_a20 -.adj2: o32 lgdt [cs:bcopy_gdt] + o32 lgdt [cs:bcopy_gdt] mov eax,cr0 or al,1 mov cr0,eax ; Enter protected mode -.adj3a: jmp 08h:.in_pm + jmp 08h:.in_pm .in_pm: mov ax,10h ; Data segment selector mov es,ax @@ -112,7 +112,7 @@ bcopy: push eax mov eax,cr0 and al,~1 mov cr0,eax ; Disable protected mode -.adj3b: jmp 0:.in_rm + jmp 0:.in_rm .in_rm: ; Back in real mode lss sp,[cs:SavedSSSP] @@ -145,11 +145,6 @@ bcopy: push eax %define A20_KBC 3 ; A20 through KBC %define A20_FAST 4 ; A20 through port 92h - align 2 -A20List dw a20_dunno, a20_none, a20_bios, a20_kbc, a20_fast -A20DList dw a20d_dunno, a20d_none, a20d_bios, a20d_kbc, a20d_fast -a20_adjust_cnt equ ($-A20List)/2 - slow_out: out dx, al ; Fall through _io_delay: out IO_DELAY_PORT,al @@ -173,7 +168,7 @@ try_enable_a20: ; mov bp,[cs:A20Type] add bp,bp ; Convert to word offset -.adj4: jmp word [cs:bp+A20List] + jmp word [cs:bp+A20List] ; ; First, see if we are on a system with no A20 gate @@ -299,7 +294,7 @@ disable_a20: mov bp,[cs:A20Type] add bp,bp ; Convert to word offset -.adj5: jmp word [cs:bp+A20DList] + jmp word [cs:bp+A20DList] a20d_bios: mov ax,2400h @@ -396,52 +391,7 @@ try_wbinvd: ; ESI, EDI, ECX - same as bcopy ; On stack - initial state (fd, ad, ds, es, fs, gs) ; -ADJUST equ (__bcopy_start - $$) + TEXT_START - BSS_START - - align 2 -adjlist dw bcopy_gdt.adj1 - ADJUST - dw bcopy.adj2 + 5 - ADJUST - dw bcopy.adj3a + 1 - ADJUST - dw bcopy.adj3b + 1 - ADJUST - dw try_enable_a20.adj4 + 3 - ADJUST - dw disable_a20.adj5 + 3 - ADJUST -adjlist_cnt equ ($-adjlist)/2 - bcopy_over_self: - push esi - push edi - push ecx - - xor bx,bx - mov es,bx - mov ds,bx - - mov si,__bcopy_start - mov di,trackbuf ; == BSS_START - mov cx,(__bcopy_end - __bcopy_start + 3) >> 2 - rep movsd - - mov si,A20List - ADJUST - mov cx,a20_adjust_cnt -.adjust1: - sub word [si], ADJUST - inc si - inc si - loop .adjust1 - - mov si, adjlist - mov cx, adjlist_cnt -.adjust2: - lodsw - xchg di,ax - sub word [di], ADJUST - loop .adjust2 - - jmp .next-ADJUST -.next: - pop ecx - pop edi - pop esi call bcopy pop gs @@ -451,9 +401,17 @@ bcopy_over_self: popad popfd jmp 0:7c00h -__bcopy_end: - section .earlybss -A20Test resw 1 ; Counter for testing status of A20 -A20Type resw 1 ; A20 type -A20Tries resb 1 ; Times until giving up on A20 + align 2 +A20List dw a20_dunno, a20_none, a20_bios, a20_kbc, a20_fast +A20DList dw a20d_dunno, a20d_none, a20d_bios, a20d_kbc, a20d_fast +a20_adjust_cnt equ ($-A20List)/2 + +A20Type dw A20_NONE ; A20 type +A20Test dw 0 ; Counter for testing status of A20 +A20Tries db 0 ; Times until giving up on A20 + + ; Total size of .bcopy32 section + alignb 4, db 0 ; Even number of dwords +__bcopy_size equ $-__bcopy_start + diff --git a/cpuinit.inc b/cpuinit.inc index 866c5f3a..8ac20f51 100644 --- a/cpuinit.inc +++ b/cpuinit.inc @@ -41,6 +41,14 @@ enough_ram: skip_checks: ; +; Initialize the bcopy32 code in low memory +; + mov si,section..bcopy32.start + mov di,__bcopy_start + mov cx,__bcopy_size >> 2 + rep movsd + +; ; Check if we're 386 (as opposed to 486+); if so we need to blank out ; the WBINVD instruction ; @@ -65,10 +73,4 @@ skip_checks: mov byte [try_wbinvd],0c3h ; Near RET is_486: %endif ; DO_WBINVD -; -; Mark A20 type as unknown. This particular word needs to be in BSS, -; so it needs to be initialized. -; - mov word [A20Type],0 - diff --git a/extlinux.asm b/extlinux.asm index fcd3fc30..dac3393f 100644 --- a/extlinux.asm +++ b/extlinux.asm @@ -22,6 +22,7 @@ %include "kernel.inc" %include "bios.inc" %include "tracers.inc" +%include "layout.inc" %include "ext2_fs.inc" @@ -107,14 +108,13 @@ file_mode resw 1 ; ; Memory below this point is reserved for the BIOS and the MBR ; -BSS_START equ 0800h - section .earlybss nobits start=BSS_START + section .earlybss trackbufsize equ 8192 trackbuf resb trackbufsize ; Track buffer goes here getcbuf resb trackbufsize ; ends at 4800h - section .bss nobits align=256 follows=.earlybss + section .bss SuperBlock resb 1024 ; ext2 superblock SuperInfo resq 16 ; DOS superblock expanded ClustSize resd 1 ; Bytes/cluster ("block") @@ -142,8 +142,6 @@ xbs_vgatmpbuf equ 2*trackbufsize section .text -TEXT_START equ 7C00h - org TEXT_START ; ; Some of the things that have to be saved very early are saved ; "close" to the initial stack pointer offset, in order to @@ -120,7 +120,7 @@ vidrows_ok: mov [VidRows],al ; VGA font buffer at the end of memory (so loading a font works even ; in graphics mode, but don't put too much pressure on the .bss) - section vgafont nobits start=0E000h + section .latebss vgafontbuf resb 8192 section .data diff --git a/isolinux.asm b/isolinux.asm index 3ba82972..4a3af1de 100644 --- a/isolinux.asm +++ b/isolinux.asm @@ -25,6 +25,7 @@ %include "kernel.inc" %include "bios.inc" %include "tracers.inc" +%include "layout.inc" ; ; Some semi-configurable constants... change on your own risk. @@ -103,14 +104,13 @@ dir_clust resd 1 ; Length in clusters ; ; Memory below this point is reserved for the BIOS and the MBR ; -BSS_START equ 0800h - section .earlybss nobits start=BSS_START + section .earlybss trackbufsize equ 8192 trackbuf resb trackbufsize ; Track buffer goes here getcbuf resb trackbufsize ; ends at 4800h - section .bss nobits align=256 follows=.earlybss + section .bss alignb 4 ISOFileName resb 64 ; ISO filename canonicalization buffer ISOFileNameEnd equ $ @@ -141,8 +141,6 @@ xbs_vgabuf equ trackbufsize xbs_vgatmpbuf equ 2*trackbufsize section .text -TEXT_START equ 7C00h - org TEXT_START ;; ;; Primary entry point. Because BIOSes are buggy, we only load the first ;; CD-ROM sector (2K) of the file, so the number one priority is actually diff --git a/ldlinux.asm b/ldlinux.asm index 2a5dfcc6..e528adb4 100644 --- a/ldlinux.asm +++ b/ldlinux.asm @@ -30,7 +30,7 @@ %include "kernel.inc" %include "bios.inc" %include "tracers.inc" - +%include "layout.inc" ; ; Some semi-configurable constants... change on your own risk. ; @@ -109,14 +109,13 @@ file_left resd 1 ; Number of sectors left ; ; Memory below this point is reserved for the BIOS and the MBR ; -BSS_START equ 0800h - section .earlybss nobits start=BSS_START + section .earlybss trackbufsize equ 8192 trackbuf resb trackbufsize ; Track buffer goes here getcbuf resb trackbufsize ; ends at 4800h - section .bss nobits align=256 follows=.earlybss + section .bss alignb 8 ; Expanded superblock @@ -152,8 +151,6 @@ xbs_vgatmpbuf equ 2*trackbufsize section .text -TEXT_START equ 7C00h - org TEXT_START ; ; Some of the things that have to be saved very early are saved ; "close" to the initial stack pointer offset, in order to diff --git a/pxelinux.asm b/pxelinux.asm index 2b7819bd..f99478e4 100644 --- a/pxelinux.asm +++ b/pxelinux.asm @@ -25,6 +25,7 @@ %include "bios.inc" %include "tracers.inc" %include "pxe.inc" +%include "layout.inc" ; ; Some semi-configurable constants... change on your own risk. @@ -175,8 +176,7 @@ tftp_pktbuf resw 1 ; Packet buffer offset ; ; Memory below this point is reserved for the BIOS and the MBR ; -BSS_START equ 0800h - section .earlybss nobits start=BSS_START + section .earlybss trackbufsize equ 8192 trackbuf resb trackbufsize ; Track buffer goes here getcbuf resb trackbufsize @@ -203,7 +203,7 @@ IPOption resb 80 ; ip= option buffer ; writing a received ARP packet into low memory. RBFG_brainfuck resb 0E00h - section .bss nobits align=256 follows=.earlybss + section .bss alignb 4 InitStack resd 1 ; Pointer to reset stack RebootTime resd 1 ; Reboot timeout, if set by option @@ -255,8 +255,6 @@ xbs_vgatmpbuf equ 2*trackbufsize ; PXELINUX needs more BSS than the other derivatives; ; therefore we relocate it from 7C00h on startup ; -TEXT_START equ 9000h - org TEXT_START StackBuf equ $-44 ; Base of stack if we use our own ; @@ -271,21 +269,22 @@ _start: push fs push gs + xor ax,ax + mov ds,ax + mov es,ax + mov si,ldlinux_end-(TEXT_START-7C00h)-4 mov di,ldlinux_end-4 mov cx,ldlinux_end-TEXT_START shr cx,2 std ; Overlapping areas, copy backwards - rep movsb + rep movsd jmp 0:_start1 ; Canonicalize address _start1: mov bp,sp les bx,[bp+48] ; ES:BX -> !PXE or PXENV+ structure - mov ax,cs - mov ds,ax - ; That is all pushed onto the PXE stack. Save the pointer ; to it and switch to an internal stack. mov [InitStack],sp |