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>
22 #include <machine/psl.h>
34 #define V86_CY(x) ((x) & PSL_C)
35 #define V86_ZR(x) ((x) & PSL_Z)
38 static struct edd_params params;
41 drvsize(struct dsk *dskp)
44 params.len = sizeof(struct edd_params);
48 v86.edx = dskp->drive;
49 v86.ds = VTOPSEG(¶ms);
50 v86.esi = VTOPOFF(¶ms);
52 if (V86_CY(v86.efl)) {
53 printf("error %u\n", v86.eax >> 8 & 0xff);
56 return (params.sectors);
61 static struct edd_packet packet;
65 drvread(struct dsk *dskp, void *buf, daddr_t lba, unsigned nblk)
67 static unsigned c = 0x2d5c7c2f;
69 if (!OPT_CHECK(RBX_QUIET))
70 printf("%c\b", c = c << 8 | c >> 24);
72 packet.len = sizeof(struct edd_packet);
74 packet.off = VTOPOFF(buf);
75 packet.seg = VTOPSEG(buf);
80 v86.edx = dskp->drive;
81 v86.ds = VTOPSEG(&packet);
82 v86.esi = VTOPOFF(&packet);
84 v86.ctl = V86_ADDR | V86_CALLF | V86_FLAGS;
85 v86.addr = XREADORG; /* call to xread in boot1 */
86 v86.es = VTOPSEG(buf);
88 v86.ebx = VTOPOFF(buf);
90 v86.edx = nblk << 8 | dskp->drive;
91 #endif /* USE_XREAD */
93 if (V86_CY(v86.efl)) {
94 printf("%s: error %u lba %u\n",
95 BOOTPROG, v86.eax >> 8 & 0xff, lba);
103 drvwrite(struct dsk *dskp, void *buf, daddr_t lba, unsigned nblk)
106 packet.len = sizeof(struct edd_packet);
108 packet.off = VTOPOFF(buf);
109 packet.seg = VTOPSEG(buf);
114 v86.edx = dskp->drive;
115 v86.ds = VTOPSEG(&packet);
116 v86.esi = VTOPOFF(&packet);
118 if (V86_CY(v86.efl)) {
119 printf("error %u lba %u\n", v86.eax >> 8 & 0xff, lba);