2 * Copyright (c) 1998 Robert Nordier
3 * Copyright (c) 2010 Pawel Jakub Dawidek <pjd@FreeBSD.org>
6 * Redistribution and use in source and binary forms are freely
7 * permitted provided that the above copyright notice and this
8 * paragraph and the following disclaimer are duplicated in all
11 * This software is provided "AS IS" and without any express or
12 * implied warranties, including, without limitation, the implied
13 * warranties of merchantability and fitness for a particular
17 #include <sys/cdefs.h>
18 __FBSDID("$FreeBSD$");
20 #include <sys/param.h>
33 static struct edd_params params;
36 drvsize(struct dsk *dskp)
39 params.len = sizeof(struct edd_params);
43 v86.edx = dskp->drive;
44 v86.ds = VTOPSEG(¶ms);
45 v86.esi = VTOPOFF(¶ms);
47 if (V86_CY(v86.efl)) {
48 printf("error %u\n", v86.eax >> 8 & 0xff);
51 return (params.sectors);
56 static struct edd_packet packet;
60 drvread(struct dsk *dskp, void *buf, daddr_t lba, unsigned nblk)
62 static unsigned c = 0x2d5c7c2f;
64 if (!OPT_CHECK(RBX_QUIET))
65 printf("%c\b", c = c << 8 | c >> 24);
67 packet.len = sizeof(struct edd_packet);
69 packet.off = VTOPOFF(buf);
70 packet.seg = VTOPSEG(buf);
75 v86.edx = dskp->drive;
76 v86.ds = VTOPSEG(&packet);
77 v86.esi = VTOPOFF(&packet);
79 v86.ctl = V86_ADDR | V86_CALLF | V86_FLAGS;
80 v86.addr = XREADORG; /* call to xread in boot1 */
81 v86.es = VTOPSEG(buf);
83 v86.ebx = VTOPOFF(buf);
85 v86.edx = nblk << 8 | dskp->drive;
86 #endif /* USE_XREAD */
88 if (V86_CY(v86.efl)) {
89 printf("%s: error %u lba %u\n",
90 BOOTPROG, v86.eax >> 8 & 0xff, lba);
98 drvwrite(struct dsk *dskp, void *buf, daddr_t lba, unsigned nblk)
101 packet.len = sizeof(struct edd_packet);
103 packet.off = VTOPOFF(buf);
104 packet.seg = VTOPSEG(buf);
109 v86.edx = dskp->drive;
110 v86.ds = VTOPSEG(&packet);
111 v86.esi = VTOPOFF(&packet);
113 if (V86_CY(v86.efl)) {
114 printf("error %u lba %u\n", v86.eax >> 8 & 0xff, lba);