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>
33 #define V86_CY(x) ((x) & PSL_C)
34 #define V86_ZR(x) ((x) & PSL_Z)
38 drvsize(struct dsk *dskp)
40 unsigned char params[0x42];
43 *(uint32_t *)params = sizeof(params);
48 v86.edx = dskp->drive;
49 v86.ds = VTOPSEG(params);
50 v86.esi = VTOPOFF(params);
52 if (V86_CY(v86.efl)) {
53 printf("error %u\n", v86.eax >> 8 & 0xff);
56 memcpy(§ors, params + 0x10, sizeof(sectors));
72 drvread(struct dsk *dskp, void *buf, daddr_t lba, unsigned nblk)
74 static unsigned c = 0x2d5c7c2f;
76 if (!OPT_CHECK(RBX_QUIET))
77 printf("%c\b", c = c << 8 | c >> 24);
81 packet.off = VTOPOFF(buf);
82 packet.seg = VTOPSEG(buf);
87 v86.edx = dskp->drive;
88 v86.ds = VTOPSEG(&packet);
89 v86.esi = VTOPOFF(&packet);
91 v86.ctl = V86_ADDR | V86_CALLF | V86_FLAGS;
92 v86.addr = XREADORG; /* call to xread in boot1 */
93 v86.es = VTOPSEG(buf);
95 v86.ebx = VTOPOFF(buf);
97 v86.edx = nblk << 8 | dskp->drive;
98 #endif /* USE_XREAD */
100 if (V86_CY(v86.efl)) {
101 printf("%s: error %u lba %u\n",
102 BOOTPROG, v86.eax >> 8 & 0xff, lba);
110 drvwrite(struct dsk *dskp, void *buf, daddr_t lba, unsigned nblk)
115 packet.off = VTOPOFF(buf);
116 packet.seg = VTOPSEG(buf);
121 v86.edx = dskp->drive;
122 v86.ds = VTOPSEG(&packet);
123 v86.esi = VTOPOFF(&packet);
125 if (V86_CY(v86.efl)) {
126 printf("error %u lba %u\n", v86.eax >> 8 & 0xff, lba);