// Write buf's contents to disk. Must be locked. void bwrite(struct buf *b) { if((b->flags & B_BUSY) == 0) panic("bwrite"); b->flags |= B_DIRTY; ide_rw(b); }
long XHReadWrite(UWORD major, UWORD minor, UWORD rw, ULONG sector, UWORD count, void *buf) { WORD dev = major; #if DBG_XHDI kprintf("XH%s(device=%d.%d, sector=%ld, count=%d, buf=%p)\n", rw ? "Write" : "Read", major, minor, sector, count, buf); #endif #if CONF_WITH_XHDI if (next_handler) { long ret = next_handler(XHREADWRITE, major, minor, rw, sector, count, buf); if (ret != EINVFN && ret != EUNDEV) return ret; } #endif #if DETECT_NATIVE_FEATURES /* direct access to device */ if (get_xhdi_nfid()) { long ret = NFCall(get_xhdi_nfid() + XHREADWRITE, (long)dev, (long)0, (long)rw, (long)sector, (long)count, buf); if (ret != EINVFN && ret != EUNDEV) return ret; } #endif if (minor != 0) return EUNDEV; /* hardware access to device */ if (FALSE) { /* Dummy case for conditional compilation */ } #if CONF_WITH_ACSI else if (dev >= 0 && dev < 8) { long ret = acsi_rw(rw, sector, count, (LONG)buf, dev); #if DBG_XHDI kprintf("acsi_rw() returned %ld\n", ret); #endif return ret; } #endif /* CONF_WITH_ACSI */ else if (dev < 16) { return EUNDEV; /* call scsi_rw() here when implemented */ } #if CONF_WITH_IDE else if (dev < 24) { long ret = ide_rw(rw, sector, count, (LONG)buf, dev - 16); #if DBG_XHDI kprintf("ide_rw() returned %ld\n", ret); #endif return ret; } #endif /* CONF_WITH_IDE */ return EUNDEV; /* unknown device */ }
// Return a B_BUSY buf with the contents of the indicated disk sector. struct buf* bread(uint dev, uint sector) { struct buf *b; b = bget(dev, sector); if(!(b->flags & B_VALID)) ide_rw(b); return b; }