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
21 ; multi-sector variant
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
41 ; Just to define it to look like SYSLINUX
45 ; %include "layout.inc"
47 m_CHS0 equ 00534843h ;'CHS',0
48 m_EDD0 equ 00444445h ;'EDD',0
49 m_EDD_SP equ 20444445h ;'EDD '
53 LDLINUX_MAGIC equ 0x3eb202fe ; A random number to identify ourselves with
58 ; global STACK_LEN, STACK_TOP, STACK_BASE
61 ; STACK_BASE equ STACK_TOP - STACK_LEN
66 %include "diskboot.inc"
74 ldlinux_magic dd LDLINUX_MAGIC
75 dd LDLINUX_MAGIC^HEXDATE
80 get_geo: ; DL and ES ready
108 ; Do we have EBIOS (EDD)?
113 mov ah,41h ; EDD existence query
118 test cl,1 ; Extended disk access functionality set
121 ; We have EDD support...
123 mov bx,dbuf ; ES should still be safe.
125 mov dword [s_chs],m_EDD_SP
127 mov eax,63 ; Same length as mov al,64; movzx eax,al
129 jc .bad_edd ;read error
134 jc .bad_edd ;read error
137 mov dword [s_type],m_EDD0
150 ; CX,DH specifies CHS address
152 getonesec_chs: ; We could use an xchg and get a loop
156 mov ax,0201h ; Read one sector
164 ; Fall through to disk_error
167 %include "geodsplib.inc"
171 ; writestr_early: write a null-terminated string to the console
172 ; This assumes we're on page 0. This is only used for early
173 ; messages, so it should be OK.
180 mov ah,0Eh ; Write to screen as TTY
181 mov bx,0007h ; Attribute
187 SuperInfo: zd 32 ; The first 16 bytes expanded 8 times
189 ; This fails if the sector overflowsg