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>
29 static struct edd_params params;
32 drvsize(struct dsk *dskp)
35 params.len = sizeof(struct edd_params);
39 v86.edx = dskp->drive;
40 v86.ds = VTOPSEG(¶ms);
41 v86.esi = VTOPOFF(¶ms);
43 if (V86_CY(v86.efl)) {
44 printf("error %u\n", v86.eax >> 8 & 0xff);
47 return (params.sectors);
50 static struct edd_packet packet;
53 drvread(struct dsk *dskp, void *buf, daddr_t lba, unsigned nblk)
55 static unsigned c = 0x2d5c7c2f;
57 if (!OPT_CHECK(RBX_QUIET))
58 printf("%c\b", c = c << 8 | c >> 24);
59 packet.len = sizeof(struct edd_packet);
61 packet.off = VTOPOFF(buf);
62 packet.seg = VTOPSEG(buf);
67 v86.edx = dskp->drive;
68 v86.ds = VTOPSEG(&packet);
69 v86.esi = VTOPOFF(&packet);
71 if (V86_CY(v86.efl)) {
72 printf("%s: error %u lba %llu\n",
73 BOOTPROG, v86.eax >> 8 & 0xff, lba);
79 #if defined(GPT) || defined(ZFS)
81 drvwrite(struct dsk *dskp, void *buf, daddr_t lba, unsigned nblk)
84 packet.len = sizeof(struct edd_packet);
86 packet.off = VTOPOFF(buf);
87 packet.seg = VTOPSEG(buf);
92 v86.edx = dskp->drive;
93 v86.ds = VTOPSEG(&packet);
94 v86.esi = VTOPOFF(&packet);
96 if (V86_CY(v86.efl)) {
97 printf("error %u lba %llu\n", v86.eax >> 8 & 0xff, lba);
102 #endif /* GPT || ZFS */