1/* $MirOS: src/sys/arch/i386/stand/libsa/biosdev2.S,v 1.8 2009/01/31 16:07:22 tg Exp $ */ 2 3/*- 4 * Copyright (c) 2009 5 * Thorsten Glaser <tg@mirbsd.org> 6 * 7 * Provided that these terms and disclaimer and all copyright notices 8 * are retained or reproduced in an accompanying document, permission 9 * is granted to deal in this work without restriction, including un- 10 * limited rights to use, publicly perform, distribute, sell, modify, 11 * merge, give away, or sublicence. 12 * 13 * This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to 14 * the utmost extent permitted by applicable law, neither express nor 15 * implied; without malicious intent or gross negligence. In no event 16 * may a licensor, author or contributor be held liable for indirect, 17 * direct, other damage, loss, or other issues arising in any way out 18 * of dealing in the work, even if advised of the possibility of such 19 * damage or existence of a defect, except proven that it results out 20 * of said person's immediate fault when using the work as intended. 21 */ 22 23 .intel_syntax noprefix 24 .text 25 .code32 26 27 .globl prot_to_real 28 .globl real_to_prot 29 30/* int biosdev_lbaprobe(int drive); */ 31/*- 32 * return value is a bitmask: 33 * 01 = LBA disc access (42h-44h, 47h, 48h) 34 * 02 = removable drv ctl (45h, 46h, 48h, 49h, INT 15h 52h) 35 * 04 = LBA disc status (48h, 4Eh) 36 * 08 = LBA installation check succeeded 37 * 10 = is a CD-ROM in El Torito "no emulation" mode 38 */ 39 .globl biosdev_lbaprobe 40 .code32 41biosdev_lbaprobe: 42 push ebp 43 mov ebp,esp 44 pushfd 45 push ebx 46 push esi 47 push edi 48 mov edi,offset bounce_buf 49 mov al,0x13 50 stosb 51 xor eax,eax 52 stosd 53 stosd 54 stosd 55 stosd 56 stosd 57 xor edx,edx 58 mov dl,[ebp+8] 59 call prot_to_real 60 .code16 61 sti 62 push edx 63 mov ah,0 64 int 0x13 65 pop edx 66 push edx 67 mov ah,0x41 68 mov bx,0x55AA 69 int 0x13 70 pop edx 71 jc LnoLBA 72 cmp bx,0xAA55 73 jne LnoLBA 74 and cl,7 75 or dh,cl /* feature mask */ 76 or dh,8 /* LBA flag */ 77LnoLBA: cmp dl,0x88 78 jb LnoCD 79 push edx 80 push ss 81 pop ds 82 xor si,si 83 mov ax,0x4B01 84 int 0x13 85 pop edx 86 jc LnoCD 87 cmp byte ptr ds:[2],dl 88 jne LnoCD 89 test byte ptr ds:[1],0x0F 90 jne LnoCD 91 or dh,16 /* CD flag */ 92LnoCD: call real_to_prot 93 .code32 94 pop edi 95 pop esi 96 pop ebx 97 xor eax,eax 98 mov al,dh 99 popfd 100 pop ebp 101 ret 102 103/* int biosdev_CHS(int ah, int dev, int cyl, int head, int sec, int nsec); */ 104/* ebp + … +8 +12 +16 +20 +24 +28 */ 105 .globl biosdev_CHS 106 .code32 107biosdev_CHS: 108 push ebp 109 mov ebp,esp 110 pushfd 111 push ebx 112 push esi 113 push edi 114 mov ecx,[ebp+16] 115 xchg ch,cl 116 shl cl,6 117 or cl,[ebp+24] 118 inc ecx 119 mov dh,[ebp+20] 120 mov dl,[ebp+12] 121 mov bh,[ebp+8] 122 mov bl,[ebp+28] 123 call prot_to_real 124 .code16 125 mov ax,bx 126 mov bx,0x3000 127 mov es,bx 128 xor bx,bx 129 push bx 130biosdev_io: 131 sti 132 int 0x13 133 pop bx 134 jnc 1f 135 mov bl,ah 1361: call real_to_prot 137 .code32 138 xor eax,eax 139 mov al,bl 140 pop edi 141 pop esi 142 pop ebx 143 popfd 144 pop ebp 145 ret 146 147/* int biosdev_LBA(int ah, int dev, u_int blk_lo, u_int blk_hi, int nsec); */ 148/* ebp + … +8 +12 +16 +20 +24 */ 149 .globl biosdev_LBA 150 .code32 151biosdev_LBA: 152 push ebp 153 mov ebp,esp 154 pushfd 155 push ebx 156 push esi 157 push edi 158 mov edi,offset biosdev_lba_buf 159 mov eax,[ebp+24] 160 shl eax,16 161 mov al,16 162 stosd 163 mov eax,0x30000000 164 stosd 165 lea esi,[ebp+16] 166 movsd 167 movsd 168 mov edx,[ebp+12] 169 mov dh,[ebp+8] 170 xor ebx,ebx 171 mov esi,offset biosdev_lba_buf - 0x30000 172 call prot_to_real 173 .code16 174 push bx 175 mov bx,0x3000 176 mov ds,bx 177 mov ah,dh 178 jmp biosdev_io 179