Releasing debian version 4.06+dfsg-2.
[syslinux-debian/hramrach.git] / com32 / gpllib / disk / util.c
blob59c0328fdd4db4e52e39bf692c35b7cf7ae4bbcc
1 /* ----------------------------------------------------------------------- *
3 * Copyright 2009 Pierre-Alexandre Meyer
5 * Some parts borrowed from chain.c32:
7 * Copyright 2003-2009 H. Peter Anvin - All Rights Reserved
8 * Copyright 2009 Intel Corporation; author: H. Peter Anvin
10 * This file is part of Syslinux, and is made available under
11 * the terms of the GNU General Public License version 2.
13 * ----------------------------------------------------------------------- */
15 #include <com32.h>
16 #include <stdlib.h>
17 #include <string.h>
18 #include <disk/geom.h>
20 #define MAX_NB_RETRIES 6
22 /**
23 * int13_retry - int13h with error handling
24 * @inreg: int13h function parameters
25 * @outreg: output registers
27 * Call int 13h, but with retry on failure. Especially floppies need this.
28 **/
29 int int13_retry(const com32sys_t * inreg, com32sys_t * outreg)
31 int retry = MAX_NB_RETRIES; /* Number of retries */
32 com32sys_t tmpregs;
34 if (!outreg)
35 outreg = &tmpregs;
37 while (retry--) {
38 __intcall(0x13, inreg, outreg);
39 if (!(outreg->eflags.l & EFLAGS_CF))
40 return 0; /* CF=0 => OK */
43 /* If we get here: error */
44 return -1;