[e16e8f2] | 1 | ; ----------------------------------------------------------------------- |
---|
| 2 | ; |
---|
| 3 | ; Copyright 2010 Gene Cumm |
---|
| 4 | ; |
---|
| 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 |
---|
| 8 | ; |
---|
| 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. |
---|
| 14 | ; |
---|
| 15 | ; ----------------------------------------------------------------------- |
---|
| 16 | |
---|
| 17 | ; |
---|
| 18 | ; geodspms.asm |
---|
| 19 | ; |
---|
| 20 | ; Display geometry translation info for diagnosing misconceptions |
---|
| 21 | ; multi-sector variant |
---|
| 22 | ; |
---|
| 23 | ; nasm -Ox -f bin -o geodsp.bin -l geodsp.lst geodsp.asm |
---|
| 24 | ; |
---|
| 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 |
---|
| 28 | ; |
---|
| 29 | ; # OF=/dev/sdb |
---|
| 30 | ; # dd if=core/geodsp.bin of=$OF |
---|
| 31 | ; # dd skip=1 seek=1 if=../dbg/lba-img/lba-img.bin of=$OF |
---|
| 32 | ; # eject $OF |
---|
| 33 | ; # dd count=$() if=/dev/zero of=$OF |
---|
| 34 | ; |
---|
| 35 | ; # OF=geo-2.255.63.i |
---|
| 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 |
---|
| 37 | ; # OF=geo-20.16.63.i |
---|
| 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 |
---|
| 39 | ; |
---|
| 40 | |
---|
| 41 | ; Just to define it to look like SYSLINUX |
---|
| 42 | %define IS_SYSLINUX 1 |
---|
| 43 | |
---|
| 44 | %include "macros.inc" |
---|
| 45 | ; %include "layout.inc" |
---|
| 46 | |
---|
| 47 | m_CHS0 equ 00534843h ;'CHS',0 |
---|
| 48 | m_EDD0 equ 00444445h ;'EDD',0 |
---|
| 49 | m_EDD_SP equ 20444445h ;'EDD ' |
---|
| 50 | retry_count equ 16 |
---|
| 51 | dbuf equ 8000h |
---|
| 52 | ; int13_ret equ 7e00h |
---|
| 53 | LDLINUX_MAGIC equ 0x3eb202fe ; A random number to identify ourselves with |
---|
| 54 | |
---|
| 55 | Sect1Ptr0_VAL equ 1 |
---|
| 56 | Sect1Ptr1_VAL equ 0 |
---|
| 57 | |
---|
| 58 | ; global STACK_LEN, STACK_TOP, STACK_BASE |
---|
| 59 | ; STACK_LEN equ 4096 |
---|
| 60 | STACK_TOP equ 7c00h |
---|
| 61 | ; STACK_BASE equ STACK_TOP - STACK_LEN |
---|
| 62 | section .init |
---|
| 63 | org STACK_TOP |
---|
| 64 | geodsp_start: |
---|
| 65 | |
---|
| 66 | %include "diskboot.inc" |
---|
| 67 | |
---|
| 68 | HEXDATE equ 1 |
---|
| 69 | |
---|
| 70 | section .init |
---|
| 71 | sector_1: |
---|
| 72 | ldlinux_sys: |
---|
| 73 | alignz 8 |
---|
| 74 | ldlinux_magic dd LDLINUX_MAGIC |
---|
| 75 | dd LDLINUX_MAGIC^HEXDATE |
---|
| 76 | |
---|
| 77 | |
---|
| 78 | ldlinux_ent: |
---|
| 79 | |
---|
| 80 | get_geo: ; DL and ES ready |
---|
| 81 | mov ah,08h |
---|
| 82 | mov di,0 |
---|
| 83 | call xint13 |
---|
| 84 | write_geo: |
---|
| 85 | jc .bad_geo |
---|
| 86 | mov si,s_chs |
---|
| 87 | call writestr_early |
---|
| 88 | call write_chs |
---|
| 89 | call crlf |
---|
| 90 | jmp short .done |
---|
| 91 | .bad_geo: |
---|
| 92 | .done: |
---|
| 93 | |
---|
| 94 | mov bx,dbuf |
---|
| 95 | get_h1c: ; 0,1,1 |
---|
| 96 | mov cx,0001h |
---|
| 97 | mov dh,01h |
---|
| 98 | call getonesec_chs |
---|
| 99 | call write_chs_lba |
---|
| 100 | get_c1c: ; 1,0,1 |
---|
| 101 | mov cx,0101h |
---|
| 102 | mov dh,00h |
---|
| 103 | call getonesec_chs |
---|
| 104 | call write_chs_lba |
---|
| 105 | |
---|
| 106 | |
---|
| 107 | |
---|
| 108 | ; Do we have EBIOS (EDD)? |
---|
| 109 | ; |
---|
| 110 | edd: |
---|
| 111 | .check: |
---|
| 112 | mov bx,55AAh |
---|
| 113 | mov ah,41h ; EDD existence query |
---|
| 114 | call xint13 |
---|
| 115 | jc .noedd |
---|
| 116 | cmp bx,0AA55h |
---|
| 117 | jne .noedd |
---|
| 118 | test cl,1 ; Extended disk access functionality set |
---|
| 119 | jz .noedd |
---|
| 120 | ; |
---|
| 121 | ; We have EDD support... |
---|
| 122 | ; |
---|
| 123 | mov bx,dbuf ; ES should still be safe. |
---|
| 124 | xor edx,edx |
---|
| 125 | mov dword [s_chs],m_EDD_SP |
---|
| 126 | .get_lba63: |
---|
| 127 | mov eax,63 ; Same length as mov al,64; movzx eax,al |
---|
| 128 | call getonesec_ebios |
---|
| 129 | jc .bad_edd ;read error |
---|
| 130 | call write_edd_lba |
---|
| 131 | .get_lba16065: |
---|
| 132 | mov eax,16065 |
---|
| 133 | call getonesec_ebios |
---|
| 134 | jc .bad_edd ;read error |
---|
| 135 | call write_edd_lba |
---|
| 136 | .good_edd: |
---|
| 137 | mov dword [s_type],m_EDD0 |
---|
| 138 | .bad_edd: |
---|
| 139 | .noedd: |
---|
| 140 | .end: |
---|
| 141 | |
---|
| 142 | write_final_type: |
---|
| 143 | mov si,s_typespec |
---|
| 144 | call writestr_early |
---|
| 145 | jmp kaboom |
---|
| 146 | |
---|
| 147 | ; |
---|
| 148 | ; getonesec_chs: |
---|
| 149 | ; |
---|
| 150 | ; CX,DH specifies CHS address |
---|
| 151 | ; |
---|
| 152 | getonesec_chs: ; We could use an xchg and get a loop |
---|
| 153 | ; mov cx,retry_count |
---|
| 154 | .retry: |
---|
| 155 | pushad |
---|
| 156 | mov ax,0201h ; Read one sector |
---|
| 157 | call xint13 |
---|
| 158 | popad |
---|
| 159 | jc .error |
---|
| 160 | ret |
---|
| 161 | |
---|
| 162 | .error: |
---|
| 163 | ; loop .retry |
---|
| 164 | ; Fall through to disk_error |
---|
| 165 | jmp disk_error |
---|
| 166 | |
---|
| 167 | %include "geodsplib.inc" |
---|
| 168 | |
---|
| 169 | ; |
---|
| 170 | ; |
---|
| 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. |
---|
| 174 | ; |
---|
| 175 | writestr_early: |
---|
| 176 | pushad |
---|
| 177 | .loop: lodsb |
---|
| 178 | and al,al |
---|
| 179 | jz .return |
---|
| 180 | mov ah,0Eh ; Write to screen as TTY |
---|
| 181 | mov bx,0007h ; Attribute |
---|
| 182 | int 10h |
---|
| 183 | jmp short .loop |
---|
| 184 | .return: popad |
---|
| 185 | ret |
---|
| 186 | |
---|
| 187 | SuperInfo: zd 32 ; The first 16 bytes expanded 8 times |
---|
| 188 | |
---|
| 189 | ; This fails if the sector overflowsg |
---|
| 190 | zb 400h-($-$$) |
---|
| 191 | end: |
---|
| 192 | |
---|
| 193 | absolute 4*1Eh |
---|
| 194 | fdctab equ $ |
---|
| 195 | fdctab1 resw 1 |
---|
| 196 | fdctab2 resw 1 |
---|