summaryrefslogtreecommitdiffstats
path: root/arch/x86/lib/bios_disk.S
blob: 3acd66047dfdbb5a24a8b891ef6e4ec240a658ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
 * Copyright (C) 2009 Juergen Beisert, Pengutronix
 *
 * Mostly stolen from the GRUB2 project
 *  Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008  Free Software Foundation, Inc.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 * MA 02111-1307 USA
 *
 */

/**
 * @file
 * @brief Do BIOS calls to load or save data from disks
 *
 * @note These functions are running in flat and real mode. Due to some
 * other restrictions these routines must running from an address
 * space below 0x10000
 */

#ifndef DOXYGEN_SHOULD_SKIP_THIS
/*
 *   int bios_disk_rw_int13_extensions (int ah, int drive, void *dap)
 *
 *   Call IBM/MS INT13 Extensions (int 13 %ah=AH) for DRIVE. DAP
 *   is passed for disk address packet. If an error occurs, return
 *   non-zero, otherwise zero.
 */
	.section .boot.text.bios_disk_rw_int13_extensions, "ax"
	.code32
	.globl bios_disk_rw_int13_extensions
	.type bios_disk_rw_int13_extensions, @function

	.extern prot_to_real
	.extern real_to_prot

bios_disk_rw_int13_extensions:
	pushl %ebp
	pushl %esi

	/* compute the address of disk_address_packet */
	movw %cx, %si
	xorw %cx, %cx
	shrl $4, %ecx	/* save the segment to cx */

	movb %al, %dh
	call prot_to_real	/* enter real mode right now */

	.code16
	movb %dh, %ah
	movw %cx, %ds
	int $0x13		/* do the operation */
	movb %ah, %dl		/* save return value */
	/* back to protected mode */
	DATA32 call real_to_prot

	.code32
	movb %dl, %al	/* return value in %eax */

	popl %esi
	popl %ebp

	ret

#endif