Merge remote branch 'pam/hdt-0.3.6'
[profile/ivi/syslinux.git] / dos / int2526.S
1 /* ----------------------------------------------------------------------- *
2  *
3  *   Copyright 1998-2008 H. Peter Anvin - All Rights Reserved
4  *   Copyright 2009 Intel Corporation; author: H. Peter Anvin
5  *
6  *   This program is free software; you can redistribute it and/or modify
7  *   it under the terms of the GNU General Public License as published by
8  *   the Free Software Foundation, Inc., 53 Temple Place Ste 330,
9  *   Boston MA 02111-1307, USA; either version 2 of the License, or
10  *   (at your option) any later version; incorporated herein by reference.
11  *
12  * ----------------------------------------------------------------------- */
13
14 /*
15  * int 0x25 and 0x26 direct sector access
16  *
17  * Use assembly wrapper functions for these system calls, since unlike
18  * int 0x21 calls they are "dirty" and can destroy unrelated registers.
19  *
20  * NOTE: these all assume the data buffer is in the data segment, i.e.
21  * %ds == %es == dio.bufseg.
22  *
23  * Usage: int int25_read_sector(drive, dio)
24  * Usage: int int26_write_sector(drive, dio)
25  */
26
27         .code16gcc
28         .text
29
30         .globl  int25_read_sector
31         .type   int25_read_sector, @function
32 int25_read_sector:
33         pushl   %ebp
34         pushl   %edi
35         pushl   %esi
36         pushl   %ebx
37
38         decw    %ax             /* AL = drive number (0 = A:) */
39         movw    %dx, %bx        /* BX = dio structure */
40         movw    6(%bx), %dx     /* DX = data buffer */
41         movw    $-1, %cx
42         int     $0x25
43         jc      1f
44         xorw    %ax, %ax        /* Error code: 0 = no error */
45 1:
46         popfw
47         movzwl  %ax, %eax
48         popl    %ebx
49         popl    %esi
50         popl    %edi
51         popl    %ebp
52         retl
53
54         .globl  int26_write_sector
55         .type   int26_write_sector, @function
56 int26_write_sector:
57         pushl   %ebp
58         pushl   %edi
59         pushl   %esi
60         pushl   %ebx
61
62         decw    %ax             /* AL = drive number (0 = A:) */
63         movw    %dx, %bx        /* BX = dio structure */
64         movw    6(%bx), %dx     /* DX = data buffer */
65         movw    $-1, %cx
66         int     $0x26
67         jc      1f
68         xorw    %ax, %ax        /* Error code: 0 = no error */
69 1:
70         popfw
71         movzwl  %ax, %eax
72         popl    %ebx
73         popl    %esi
74         popl    %edi
75         popl    %ebp
76         retl