1 ; -----------------------------------------------------------------------
3 ; Copyright 2010 Gene Cumm
5 ; Portions from diskstart.inc:
6 ; Copyright 1994-2009 H. Peter Anvin - All Rights Reserved
7 ; Copyright 2009-2010 Intel Corporation; author: H. Peter Anvin
9 ; This program is free software; you can redistribute it and/or modify
10 ; it under the terms of the GNU General Public License as published by
11 ; the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
12 ; Boston MA 02110-1301, USA; either version 2 of the License, or
13 ; (at your option) any later version; incorporated herein by reference.
15 ; -----------------------------------------------------------------------
20 ; Display geometry translation info for diagnosing misconceptions
23 ; nasm -Ox -f bin -o geodsp.bin -l geodsp.lst geodsp.asm
25 ; nasm -Ox -f elf -o geodsp.o -l geodsp.lst geodsp.asm
26 ; ld -m elf_i386 -T syslinux.ld -M -o geodsp.elf geodsp.o > geodsp.map
27 ; objcopy -O binary geodsp.elf geodsp.raw
30 ; # dd if=core/geodsp.bin of=$OF
31 ; # dd skip=1 seek=1 if=../dbg/lba-img/lba-img.bin of=$OF
33 ; # dd count=$() if=/dev/zero of=$OF
36 ; # (dd if=core/geodsp.bin; dd skip=1 if=../dbg/lba-img/lba-img.bin; dd count=$((2*255*63 - 256*63 - 1)) if=/dev/zero )|dd of=$OF
38 ; # (dd if=core/geodsp.bin; dd skip=1 if=../dbg/lba-img/lba-img.bin; dd count=$((40*16*63 - 256*63 - 1)) if=/dev/zero )|dd of=$OF
42 ; %include "layout.inc"
44 ; global STACK_LEN, STACK_TOP, STACK_BASE
47 ; STACK_BASE equ STACK_TOP - STACK_LEN
49 StackBuf
equ STACK_TOP
-44-92 ; Start the stack here (grow down - 4K)
50 DriveNumber
equ StackBuf
-4 ; Drive number
51 m_CHS0
equ 00534843h ;'CHS',0
52 m_EDD0
equ 00444445h ;'EDD',0
53 m_EDD_SP
equ 20444445h ;'EDD '
60 ; extern real_mode_seg
61 ; section .real_mode write nobits align=65536
62 ; global core_real_mode
63 ; core_real_mode resb 65536
65 ; section .xfer_buf write nobits align=65536
66 ; global core_xfer_buf
67 ; core_xfer_buf resb 65536
76 ; In case we want to pull more of the standard diskstart stuff in
77 ; jmp short start ; 2 bytes
84 mov sp,StackBuf
-2 ; Just below BSS (-2 for alignment)
85 push dx ; Save drive number (in DL)
86 ; Kill everything else and let the BIOS sort it out later
91 get_geo: ; DL and ES ready
118 ; Do we have EBIOS (EDD)?
123 mov ah,41h ; EDD existence query
129 test cl,1 ; Extended disk access functionality set
132 ; We have EDD support...
136 mov dword [s_chs
],m_EDD_SP
138 mov eax,63 ; Same length as mov al,64; movzx eax,al
140 jc .bad_edd
;read error
145 jc .bad_edd
;read error
148 mov dword [s_type
],m_EDD0
162 ; getonesec implementation for EBIOS (EDD)
176 mov ah,42h ; Extended Read
179 lea sp,[si+16] ; Remove DAPA
184 ; Some systems seem to get "stuck" in an error state when
185 ; using EBIOS. Doesn't happen when using CBIOS, which is
186 ; good, since some other systems get timeout failures
187 ; waiting for the floppy disk to spin up.
189 pushad ; Try resetting the device
193 loop .retry
; CX-- and jump if not zero
202 ; CX,DH specifies CHS address
204 getonesec_chs: ; We could use an xchg and get a loop
208 mov ax,0201h ; Read one sector
216 ; Fall through to disk_error
218 ; kaboom: write a message and bail out.
227 .
again: int 16h ; Wait for keypress
228 ; NB: replaced by int 18h if
229 ; chosen at install time..
230 int 19h ; And try once more to boot...
231 .
norge: hlt ; If int 19h returned; this is the end
235 ; INT 13h wrapper function
245 ; writestr_early: write a null-terminated string to the console
246 ; This assumes we're on page 0. This is only used for early
247 ; messages, so it should be OK.
259 %include "geodsplib.inc"
262 ; This fails if the boot sector overflowsg
265 ptable zb
40h ; Partition table
267 bootsignature
dw 0xAA55