if (w_prepare(w_drive * DEV_PER_DRIVE) == NIL_DEV)
panic(w_name(), "Couldn't switch devices", NO_NUM);
- r = w_transfer(SELF, DEV_GATHER, cvu64(0), &iov, 1, 0);
+ r = w_transfer(SELF, DEV_GATHER_S, cvu64(0), &iov, 1, 0);
/* Switch back. */
if (w_prepare(save_dev) == NIL_DEV)
cmd.count = count;
if (do_dma)
{
- cmd.command = opcode == DEV_SCATTER ? CMD_WRITE_DMA :
+ cmd.command = opcode == DEV_SCATTER_S ? CMD_WRITE_DMA :
CMD_READ_DMA;
}
else
- cmd.command = opcode == DEV_SCATTER ? CMD_WRITE : CMD_READ;
+ cmd.command = opcode == DEV_SCATTER_S ? CMD_WRITE : CMD_READ;
if (do_lba48) {
if (do_dma)
{
- cmd.command = ((opcode == DEV_SCATTER) ?
+ cmd.command = ((opcode == DEV_SCATTER_S) ?
CMD_WRITE_DMA_EXT : CMD_READ_DMA_EXT);
}
else
{
- cmd.command = ((opcode == DEV_SCATTER) ?
+ cmd.command = ((opcode == DEV_SCATTER_S) ?
CMD_WRITE_EXT : CMD_READ_EXT);
}
cmd.count_prev= (count >> 8);
*===========================================================================*/
PRIVATE int w_transfer(proc_nr, opcode, position, iov, nr_req, safe)
int proc_nr; /* process doing the request */
-int opcode; /* DEV_GATHER or DEV_SCATTER */
+int opcode; /* DEV_GATHER_S or DEV_SCATTER_S */
u64_t position; /* offset on device to read or write */
iovec_t *iov; /* pointer to read or write request vector */
unsigned nr_req; /* length of request vector */
block = div64u(add64(w_dv->dv_base, position), SECTOR_SIZE);
do_dma= wn->dma;
- do_write= (opcode == DEV_SCATTER);
+ do_write= (opcode == DEV_SCATTER_S);
if (nbytes >= wn->max_count) {
/* The drive can't do more then max_count at once. */
r = do_transfer(wn, wn->precomp, (nbytes >> SECTOR_SHIFT),
block, opcode, do_dma);
- if (opcode == DEV_SCATTER) {
+ if (opcode == DEV_SCATTER_S) {
/* The specs call for a 400 ns wait after issuing the command.
* Reading the alternate status register is the suggested
* way to implement this wait.
* interrupt (write).
*/
- if (opcode == DEV_GATHER) {
+ if (opcode == DEV_GATHER_S) {
/* First an interrupt, then data. */
if ((r = at_intr_wait()) != OK) {
/* An error, send data to the bit bucket. */
if (!w_waitfor(STATUS_DRQ, STATUS_DRQ)) { r = ERR; break; }
/* Copy bytes to or from the device's buffer. */
- if (opcode == DEV_GATHER) {
+ if (opcode == DEV_GATHER_S) {
if(safe) {
s=sys_safe_insw(wn->base_cmd + REG_DATA, proc_nr,
(void *) (iov->iov_addr), addr_offset,
*===========================================================================*/
PRIVATE int atapi_transfer(proc_nr, opcode, position, iov, nr_req, safe)
int proc_nr; /* process doing the request */
-int opcode; /* DEV_GATHER or DEV_SCATTER */
+int opcode; /* DEV_GATHER_S or DEV_SCATTER_S */
u64_t position; /* offset on device to read or write */
iovec_t *iov; /* pointer to read or write request vector */
unsigned nr_req; /* length of request vector */
{
int r, timeout, prev;
- if (m->m_type != DEV_IOCTL && m->m_type != DEV_IOCTL_S ) {
+ if (m->m_type != DEV_IOCTL_S )
return EINVAL;
- }
if (m->REQUEST == DIOCTIMEOUT) {
if(safe) {
/* Degrade to per-sector mode if there were errors. */
if (errors > 0) nbytes = SECTOR_SIZE;
- if (opcode == DEV_SCATTER) {
+ if (opcode == DEV_SCATTER_S) {
/* Copy from user space to the DMA buffer. */
count = 0;
for (iop = iov; count < nbytes; iop++) {
/* Set up an extended read or write BIOS call. */
reg86.u.b.intno = 0x13;
- reg86.u.w.ax = opcode == DEV_SCATTER ? 0x4300 : 0x4200;
+ reg86.u.w.ax = opcode == DEV_SCATTER_S ? 0x4300 : 0x4200;
reg86.u.b.dl = wn->drive_id;
reg86.u.w.si = (bios_buf_phys + i13e_rw_off) % HCLICK_SIZE;
reg86.u.w.ds = (bios_buf_phys + i13e_rw_off) / HCLICK_SIZE;
unsigned head = (block % secspcyl) / wn->sectors;
reg86.u.b.intno = 0x13;
- reg86.u.b.ah = opcode == DEV_SCATTER ? 0x03 : 0x02;
+ reg86.u.b.ah = opcode == DEV_SCATTER_S ? 0x03 : 0x02;
reg86.u.b.al = nbytes >> SECTOR_SHIFT;
reg86.u.w.bx = bios_buf_phys % HCLICK_SIZE;
reg86.u.w.es = bios_buf_phys / HCLICK_SIZE;
continue;
}
- if (opcode == DEV_GATHER) {
+ if (opcode == DEV_GATHER_S) {
/* Copy from the DMA buffer to user space. */
count = 0;
for (iop = iov; count < nbytes; iop++) {
{
int r, timeout, prev;
- if (m->m_type != DEV_IOCTL && m->m_type != DEV_IOCTL_S ) {
+ if (m->m_type != DEV_IOCTL_S )
return EINVAL;
- }
if (m->REQUEST == DIOCOPENCT) {
int count;
*===========================================================================*/
PRIVATE int f_transfer(proc_nr, opcode, pos64, iov, nr_req, safe)
int proc_nr; /* process doing the request */
-int opcode; /* DEV_GATHER or DEV_SCATTER */
+int opcode; /* DEV_GATHER_S or DEV_SCATTER_S */
u64_t pos64; /* offset on device to read or write */
iovec_t *iov; /* pointer to read or write request vector */
unsigned nr_req; /* length of request vector */
/* Using a formatting device? */
if (f_device & FORMAT_DEV_BIT) {
- if (opcode != DEV_SCATTER) return(EIO);
+ if (opcode != DEV_SCATTER_S) return(EIO);
if (iov->iov_size < SECTOR_SIZE + sizeof(fmt_param))
return(EINVAL);
}
}
- if (r == OK && opcode == DEV_SCATTER) {
+ if (r == OK && opcode == DEV_SCATTER_S) {
/* Copy the user bytes to the DMA buffer. */
if(safe) {
s=sys_safecopyfrom(proc_nr, *ug, *up,
r = fdc_transfer(opcode);
}
- if (r == OK && opcode == DEV_GATHER) {
+ if (r == OK && opcode == DEV_GATHER_S) {
/* Copy the DMA buffer to user space. */
if(safe) {
s=sys_safecopyto(proc_nr, *ug, *up,
* dma_setup *
*===========================================================================*/
PRIVATE int dma_setup(opcode)
-int opcode; /* DEV_GATHER or DEV_SCATTER */
+int opcode; /* DEV_GATHER_S or DEV_SCATTER_S */
{
/* The IBM PC can perform DMA operations by using the DMA chip. To use it,
* the DMA (Direct Memory Access) chip is loaded with the 20-bit memory address
*/
pv_set(byte_out[0], DMA_INIT, DMA_RESET_VAL); /* reset the dma controller */
pv_set(byte_out[1], DMA_FLIPFLOP, 0); /* write anything to reset it */
- pv_set(byte_out[2], DMA_MODE, opcode == DEV_SCATTER ? DMA_WRITE : DMA_READ);
+ pv_set(byte_out[2], DMA_MODE, opcode == DEV_SCATTER_S ? DMA_WRITE : DMA_READ);
pv_set(byte_out[3], DMA_ADDR, (unsigned) tmp_phys >> 0);
pv_set(byte_out[4], DMA_ADDR, (unsigned) tmp_phys >> 8);
pv_set(byte_out[5], DMA_TOP, (unsigned) (tmp_phys >> 16));
* fdc_transfer *
*===========================================================================*/
PRIVATE int fdc_transfer(opcode)
-int opcode; /* DEV_GATHER or DEV_SCATTER */
+int opcode; /* DEV_GATHER_S or DEV_SCATTER_S */
{
/* The drive is now on the proper cylinder. Read, write or format 1 block. */
cmd[5] = fmt_param.fill_byte_for_format;
if (fdc_command(cmd, 6) != OK) return(ERR_TRANSFER);
} else {
- cmd[0] = opcode == DEV_SCATTER ? FDC_WRITE : FDC_READ;
+ cmd[0] = opcode == DEV_SCATTER_S ? FDC_WRITE : FDC_READ;
cmd[1] = (fp->fl_head << 2) | f_drive;
cmd[2] = fp->fl_cylinder;
cmd[3] = fp->fl_head;
position = (off_t) f_dp->test << SECTOR_SHIFT;
iovec1.iov_addr = (vir_bytes) tmp_buf;
iovec1.iov_size = SECTOR_SIZE;
- result = f_transfer(SELF, DEV_GATHER, cvul64(position), &iovec1, 1, 0);
+ result = f_transfer(SELF, DEV_GATHER_S, cvul64(position), &iovec1, 1, 0);
if (iovec1.iov_size != 0) return(EIO);
* driver_task: called by the device dependent task entry
*/
+
#include "../drivers.h"
#include <sys/ioc_disk.h>
#include <minix/mq.h>
switch(mess.m_type) {
case DEV_OPEN: r = (*dp->dr_open)(dp, &mess); break;
case DEV_CLOSE: r = (*dp->dr_close)(dp, &mess); break;
+#ifdef DEV_IOCTL
case DEV_IOCTL: r = (*dp->dr_ioctl)(dp, &mess, 0); break;
+#endif
case DEV_IOCTL_S: r = (*dp->dr_ioctl)(dp, &mess, 1); break;
case CANCEL: r = (*dp->dr_cancel)(dp, &mess);break;
case DEV_SELECT: r = (*dp->dr_select)(dp, &mess);break;
+#ifdef DEV_READ
case DEV_READ:
case DEV_WRITE: r = do_rdwt(dp, &mess, 0); break;
+#endif
case DEV_READ_S:
case DEV_WRITE_S: r = do_rdwt(dp, &mess, 1); break;
+#ifdef DEV_GATHER
case DEV_GATHER:
case DEV_SCATTER: r = do_vrdwt(dp, &mess, 0); break;
+#endif
case DEV_GATHER_S:
case DEV_SCATTER_S: r = do_vrdwt(dp, &mess, 1); break;
if ((*dp->dr_prepare)(mp->DEVICE) == NIL_DEV) return(ENXIO);
/* Create a one element scatter/gather vector for the buffer. */
- if(mp->m_type == DEV_READ || mp->m_type == DEV_READ_S) opcode = DEV_GATHER;
- else opcode = DEV_SCATTER;
+ if(
+#ifdef DEV_READ
+ mp->m_type == DEV_READ ||
+#endif
+ mp->m_type == DEV_READ_S) opcode = DEV_GATHER_S;
+ else opcode = DEV_SCATTER_S;
iovec1.iov_addr = (vir_bytes) mp->ADDRESS;
iovec1.iov_size = mp->COUNT;
/* Transfer bytes from/to the device. */
opcode = mp->m_type;
- if(opcode == DEV_GATHER_S) opcode = DEV_GATHER;
- if(opcode == DEV_SCATTER_S) opcode = DEV_SCATTER;
position= make64(mp->POSITION, mp->HIGHPOS);
r = (*dp->dr_transfer)(mp->IO_ENDPT, opcode, position, iov,
nr_req, safe);
switch (mp->m_type) {
case DEV_OPEN: return(ENODEV);
case DEV_CLOSE: return(OK);
+ case DEV_IOCTL_S:
+#ifdef DEV_IOCTL
case DEV_IOCTL: return(ENOTTY);
+#endif
default: printf("nop: ignoring code %d\n", mp->m_type); return(EIO);
}
}
iovec1.iov_addr = (vir_bytes) partbuf;
iovec1.iov_size = CD_SECTOR_SIZE;
if ((*dp->dr_prepare)(device) != NIL_DEV) {
- (void) (*dp->dr_transfer)(SELF, DEV_GATHER, position, &iovec1, 1, 0);
+ (void) (*dp->dr_transfer)(SELF, DEV_GATHER_S, position, &iovec1, 1, 0);
}
if (iovec1.iov_size != 0) {
return 0;
*===========================================================================*/
PRIVATE int log_transfer(proc_nr, opcode, position, iov, nr_req, safe)
int proc_nr; /* process doing the request */
-int opcode; /* DEV_GATHER or DEV_SCATTER */
+int opcode; /* DEV_GATHER_S or DEV_SCATTER_S */
u64_t position; /* offset on device to read or write */
iovec_t *iov; /* pointer to read or write request vector */
unsigned nr_req; /* length of request vector */
switch (log_device) {
case MINOR_KLOG:
- if (opcode == DEV_GATHER) {
+ if (opcode == DEV_GATHER_S) {
if (log->log_proc_nr || count < 1) {
/* There's already someone hanging to read, or
* no real I/O requested.
*===========================================================================*/
PRIVATE int m_transfer(proc_nr, opcode, pos64, iov, nr_req, safe)
int proc_nr; /* process doing the request */
-int opcode; /* DEV_GATHER or DEV_SCATTER */
+int opcode; /* DEV_GATHER_S or DEV_SCATTER_S */
u64_t pos64; /* offset on device to read or write */
iovec_t *iov; /* pointer to read or write request vector */
unsigned nr_req; /* length of request vector */
/* No copying; ignore request. */
case NULL_DEV:
- if (opcode == DEV_GATHER) return(OK); /* always at EOF */
+ if (opcode == DEV_GATHER_S) return(OK); /* always at EOF */
break;
/* Virtual copying. For RAM disk, kernel memory and boot device. */
if (position + count > dv_size) count = dv_size - position;
seg = m_seg[m_device];
- if (opcode == DEV_GATHER) { /* copy actual data */
+ if (opcode == DEV_GATHER_S) { /* copy actual data */
if(safe) {
r=sys_safecopyto(proc_nr, user_vir, vir_offset,
position, count, seg);
panic("MEM","sys_umap failed in m_transfer",r);
}
- if (opcode == DEV_GATHER) { /* copy data */
+ if (opcode == DEV_GATHER_S) { /* copy data */
sys_physcopy(NONE, PHYS_SEG, mem_phys,
NONE, PHYS_SEG, user_phys + vir_offset, count);
} else {
/* Null byte stream generator. */
case ZERO_DEV:
- if (opcode == DEV_GATHER) {
+ if (opcode == DEV_GATHER_S) {
size_t suboffset = 0;
left = count;
while (left > 0) {
if (position >= dv_size) return(OK); /* check for EOF */
if (position + count > dv_size) count = dv_size - position;
- if (opcode == DEV_GATHER) { /* copy actual data */
+ if (opcode == DEV_GATHER_S) { /* copy actual data */
if(safe) {
s=sys_safecopyto(proc_nr, user_vir, vir_offset,
(vir_bytes)&imgrd[position], count, D);
case DEV_CLOSE:
reply(TASK_REPLY, pr_mess.m_source, pr_mess.IO_ENDPT, OK);
break;
- case DEV_WRITE: do_write(&pr_mess, 0); break;
case DEV_WRITE_S: do_write(&pr_mess, 1); break;
case DEV_STATUS: do_status(&pr_mess); break;
case CANCEL: do_cancel(&pr_mess); break;
/* Random number generator. Character instead of block device. */
case RANDOM_DEV:
- if (opcode == DEV_GATHER && !random_isseeded())
+ if (opcode == DEV_GATHER_S && !random_isseeded())
return(EAGAIN);
left = count;
while (left > 0) {
chunk = (left > RANDOM_BUF_SIZE) ? RANDOM_BUF_SIZE : left;
- if (opcode == DEV_GATHER) {
+ if (opcode == DEV_GATHER_S) {
random_getbytes(random_buf, chunk);
if(safe) {
r= sys_safecopyto(proc_nr, user_vir, vir_offset,
sys_vircopy(SELF, D, (vir_bytes) random_buf,
proc_nr, D, user_vir + vir_offset, chunk);
}
- } else if (opcode == DEV_SCATTER) {
+ } else if (opcode == DEV_SCATTER_S) {
if(safe) {
r= sys_safecopyfrom(proc_nr, user_vir, vir_offset,
(vir_bytes) random_buf, chunk, D);
switch(mess.m_type) {
case DEV_OPEN: r = dsp_open(); break;
case DEV_CLOSE: r = dsp_close(); break;
+#ifdef DEV_IOCTL
case DEV_IOCTL: r = dsp_ioctl(&mess); break;
+#endif
+#ifdef DEV_READ
case DEV_READ: r = EINVAL; break; /* Not yet implemented */
case DEV_WRITE: dsp_write(&mess); continue; /* don't reply */
+#endif
case DEV_STATUS: dsp_status(&mess); continue; /* don't reply */
case HARD_INT: dsp_hardware_msg(); continue; /* don't reply */
if(DmaBusy < 0) { /* Dma tranfer not yet started */
- DmaMode = DEV_WRITE; /* Dma mode is writing */
+ DmaMode = DEV_WRITE_S; /* Dma mode is writing */
sys_datacopy(m_ptr->IO_ENDPT, (vir_bytes)m_ptr->ADDRESS, SELF, (vir_bytes)DmaPtr, (phys_bytes)DspFragmentSize);
dsp_dma_setup(DmaPhys, DspFragmentSize * DMA_NR_OF_BUFFERS);
dsp_setup();
pv_set(pvb[1], DMA8_CLEAR, 0x00); /* Clear flip flop */
/* set DMA mode */
- pv_set(pvb[2], DMA8_MODE, (DmaMode == DEV_WRITE ? DMA8_AUTO_PLAY : DMA8_AUTO_REC));
+ pv_set(pvb[2], DMA8_MODE, (DmaMode == DEV_WRITE_S ? DMA8_AUTO_PLAY : DMA8_AUTO_REC));
pv_set(pvb[3], DMA8_ADDR, address >> 0); /* Low_byte of address */
pv_set(pvb[4], DMA8_ADDR, address >> 8); /* High byte of address */
pv_set(pvb[1], DMA16_CLEAR, 0x00); /* Clear flip flop */
/* Set dma mode */
- pv_set(pvb[2], DMA16_MODE, (DmaMode == DEV_WRITE ? DMA16_AUTO_PLAY : DMA16_AUTO_REC));
+ pv_set(pvb[2], DMA16_MODE, (DmaMode == DEV_WRITE_S ? DMA16_AUTO_PLAY : DMA16_AUTO_REC));
pv_set(pvb[3], DMA16_ADDR, (address >> 1) & 0xFF); /* Low_byte of address */
pv_set(pvb[4], DMA16_ADDR, (address >> 9) & 0xFF); /* High byte of address */
dsp_set_speed(DspSpeed);
/* Put the speaker on */
- if(DmaMode == DEV_WRITE) {
+ if(DmaMode == DEV_WRITE_S) {
dsp_command (DSP_CMD_SPKON); /* put speaker on */
/* Program DSP with dma mode */
switch(mess.m_type) {
case DEV_OPEN: err = mixer_open(&mess); break;
case DEV_CLOSE: err = mixer_close(&mess); break;
+#ifdef DEV_IOCTL
case DEV_IOCTL: err = mixer_ioctl(&mess); break;
+#endif
default: err = EINVAL; break;
}
break;
case DEV_IOCTL_S:
safe=1;
- /* Fallthrough. */
- case DEV_IOCTL:
if (m->TTY_REQUEST == MIOCMAP || m->TTY_REQUEST == MIOCUNMAP)
{
int r, do_map;
break;
case DEV_READ_S:
safecopy = 1;
- /* Fallthrough. */
- case DEV_READ:
if (kbdp->req_size)
{
/* We handle only request at a time */
case DEV_WRITE_S:
safecopy = 1;
- /* Fallthrough. */
- case DEV_WRITE:
if (kbdp != &kbdaux)
{
printf("write to keyboard not implemented\n");
break;
case DEV_IOCTL_S:
safecopy=1;
- /* Fallthrough. */
- case DEV_IOCTL:
if (kbdp == &kbd && m->TTY_REQUEST == KIOCSLEDS)
{
kio_leds_t leds;
switch (m_ptr->m_type) {
case DEV_READ_S:
safe=1;
- /* fallthrough */
- case DEV_READ:
/* Check, store information on the reader, do I/O. */
if (pp->state & TTY_CLOSED) {
r = 0;
case DEV_WRITE_S:
safe=1;
- /* fallthrough */
- case DEV_WRITE:
/* Check, store information on the writer, do I/O. */
if (pp->state & TTY_CLOSED) {
r = EIO;
tp = tty_addr(line - TTYPX_MINOR + NR_CONS + NR_RS_LINES);
} else if ((line - PTYPX_MINOR) < NR_PTYS) {
tp = tty_addr(line - PTYPX_MINOR + NR_CONS + NR_RS_LINES);
- if (tty_mess.m_type != DEV_IOCTL &&
- tty_mess.m_type != DEV_IOCTL_S) {
+ if (tty_mess.m_type != DEV_IOCTL_S) {
do_pty(tp, &tty_mess);
continue;
}
/* Execute the requested device driver function. */
switch (tty_mess.m_type) {
- case DEV_READ: do_read(tp, &tty_mess, 0); break;
case DEV_READ_S: do_read(tp, &tty_mess, 1); break;
- case DEV_WRITE: do_write(tp, &tty_mess, 0); break;
case DEV_WRITE_S: do_write(tp, &tty_mess, 1); break;
- case DEV_IOCTL: do_ioctl(tp, &tty_mess, 0); break;
case DEV_IOCTL_S: do_ioctl(tp, &tty_mess, 1); break;
case DEV_OPEN: do_open(tp, &tty_mess); break;
case DEV_CLOSE: do_close(tp, &tty_mess); break;
#define DEV_RS_BASE 0x500 /* base for device response types */
#define CANCEL (DEV_RQ_BASE + 0) /* force a task to cancel */
-#define DEV_READ (DEV_RQ_BASE + 3) /* read from minor device */
-#define DEV_WRITE (DEV_RQ_BASE + 4) /* write to minor device */
-#define DEV_IOCTL (DEV_RQ_BASE + 5) /* I/O control code */
#define DEV_OPEN (DEV_RQ_BASE + 6) /* open a minor device */
#define DEV_CLOSE (DEV_RQ_BASE + 7) /* close a minor device */
-#define DEV_SCATTER (DEV_RQ_BASE + 8) /* write from a vector */
-#define DEV_GATHER (DEV_RQ_BASE + 9) /* read into a vector */
#define TTY_SETPGRP (DEV_RQ_BASE + 10) /* set process group */
#define TTY_EXIT (DEV_RQ_BASE + 11) /* process group leader exited */
#define DEV_SELECT (DEV_RQ_BASE + 12) /* request select() attention */
send_reply= 1;
free_mess= 1;
break;
+#ifdef DEV_READ
case DEV_READ:
case DEV_WRITE:
case DEV_IOCTL3:
send_reply= (result == SUSPEND);
free_mess= 0;
break;
+#endif
case DEV_READ_S:
case DEV_WRITE_S:
case DEV_IOCTL_S:
switch(m->mq_mess.m_type)
{
+#ifdef DEV_READ
case DEV_READ:
q_head_ptr= &sr_fd->srf_read_q;
q_tail_ptr= &sr_fd->srf_read_q_tail;
susp_flag= SFF_IOCTL_SUSP;
first_flag= SFF_IOCTL_FIRST;
break;
+#endif
default:
ip_panic(("illegal case entry"));
}
switch(m->mq_mess.m_type)
{
+#ifdef DEV_READ
case DEV_READ:
r= (*sr_fd->srf_read)(sr_fd->srf_fd,
m->mq_mess.NDEV_COUNT);
}
r= (*sr_fd->srf_ioctl)(sr_fd->srf_fd, request);
break;
+#endif
default:
ip_panic(("illegal case entry"));
}
}
else
{
+#ifdef DEV_READ
assert(m_type == DEV_READ || m_type == DEV_WRITE ||
m_type == DEV_IOCTL);
+#else
+ ip_panic(("sr_get_userdata: m_type not *_S\n"));
+#endif
safe_copy= 0;
}
}
else
{
+#ifdef DEV_READ
assert(m_type == DEV_READ || m_type == DEV_WRITE ||
m_type == DEV_IOCTL);
+#else
+ ip_panic(("sr_put_userdata: m_type not *_S\n"));
+#endif
safe_copy= 0;
}
if ( (dev = bp->b_dev) != NO_DEV) {
pos = mul64u(bp->b_blocknr, block_size);
- op = (rw_flag == READING ? DEV_READ : DEV_WRITE);
+ op = (rw_flag == READING ? MFS_DEV_READ : MFS_DEV_WRITE);
r = block_dev_io(op, dev, SELF_E, bp->b_data, pos, block_size, 0);
if (r != block_size) {
if (r >= 0) r = END_OF_FILE;
iop->iov_addr = (vir_bytes) bp->b_data;
iop->iov_size = block_size;
}
- r = block_dev_io(rw_flag == WRITING ? DEV_SCATTER : DEV_GATHER,
+ r = block_dev_io(rw_flag == WRITING ? MFS_DEV_SCATTER : MFS_DEV_GATHER,
dev, SELF_E, iovec,
mul64u(bufq[0]->b_blocknr, block_size), j, 0);
#define MFS_MIN(a,b) mfs_min_f(__FILE__,__LINE__,(a), (b))
#define MFS_NUL(str,l,m) mfs_nul_f(__FILE__,__LINE__,(str), (l), (m))
+
+/* Args to dev_bio/dev_io */
+#define MFS_DEV_READ 10001
+#define MFS_DEV_WRITE 10002
+#define MFS_DEV_SCATTER 10003
+#define MFS_DEV_GATHER 10004
+
*gid = GRANT_INVALID;
switch(*op) {
- case DEV_READ:
- case DEV_WRITE:
+ case MFS_DEV_READ:
+ case MFS_DEV_WRITE:
/* Change to safe op. */
- *op = *op == DEV_READ ? DEV_READ_S : DEV_WRITE_S;
+ *op = *op == MFS_DEV_READ ? DEV_READ_S : DEV_WRITE_S;
if((*gid=cpf_grant_direct(driver, (vir_bytes) *buf,
bytes, *op == DEV_READ_S ? CPF_WRITE :
}
break;
- case DEV_GATHER:
- case DEV_SCATTER:
+ case MFS_DEV_GATHER:
+ case MFS_DEV_SCATTER:
/* Change to safe op. */
- *op = *op == DEV_GATHER ? DEV_GATHER_S : DEV_SCATTER_S;
+ *op = *op == MFS_DEV_GATHER ?
+ DEV_GATHER_S : DEV_SCATTER_S;
/* Grant access to my new i/o vector. */
if((*gid = cpf_grant_direct(driver,
* block_dev_io *
*===========================================================================*/
PUBLIC int block_dev_io(op, dev, proc_e, buf, pos, bytes, flags)
-int op; /* DEV_READ, DEV_WRITE, DEV_IOCTL, etc. */
+int op; /* MFS_DEV_READ, MFS_DEV_WRITE, etc. */
dev_t dev; /* major-minor device number */
int proc_e; /* in whose address space is buf? */
void *buf; /* virtual address of the buffer */
if (dev == NO_DEV)
panic(__FILE__,"request for super_block of NO_DEV", NO_NUM);
- r = block_dev_io(DEV_READ, dev, SELF_E,
+ r = block_dev_io(MFS_DEV_READ, dev, SELF_E,
sbbuf, cvu64(SUPER_BLOCK_BYTES), _MIN_BLOCK_SIZE, 0);
if (r != _MIN_BLOCK_SIZE) {
printf("MFSread_super r != _MIN_BLOCK_SIZE\n");
#define V2_INODE_SIZE usizeof (d2_inode) /* bytes in V2 dsk ino */
#define V2_INDIRECTS(b) ((b)/V2_ZONE_NUM_SIZE) /* # zones/indir block */
#define V2_INODES_PER_BLOCK(b) ((b)/V2_INODE_SIZE)/* # V2 dsk inodes/blk */
+
+/* Args to dev_bio/dev_io */
+#define VFS_DEV_READ 2001
+#define VFS_DEV_WRITE 2002
+#define VFS_DEV_SCATTER 2003
+#define VFS_DEV_GATHER 2004
+#define VFS_DEV_IOCTL 2005
+#define VFS_DEV_SELECT 2006
*gid = GRANT_INVALID;
switch(*op) {
- case DEV_READ:
- case DEV_WRITE:
+ case VFS_DEV_READ:
+ case VFS_DEV_WRITE:
/* Change to safe op. */
- *op = *op == DEV_READ ? DEV_READ_S : DEV_WRITE_S;
+ *op = *op == VFS_DEV_READ ? DEV_READ_S : DEV_WRITE_S;
if((*gid=cpf_grant_magic(driver, *io_ept,
(vir_bytes) *buf, bytes,
}
break;
- case DEV_GATHER:
- case DEV_SCATTER:
+ case VFS_DEV_GATHER:
+ case VFS_DEV_SCATTER:
/* Change to safe op. */
- *op = *op == DEV_GATHER ? DEV_GATHER_S : DEV_SCATTER_S;
+ *op = *op == VFS_DEV_GATHER ?
+ DEV_GATHER_S : DEV_SCATTER_S;
/* Grant access to my new i/o vector. */
if((*gid = cpf_grant_direct(driver,
/* Set user's vector to the new one. */
*buf = new_iovec;
break;
- case DEV_IOCTL:
+ case VFS_DEV_IOCTL:
*pos = *io_ept; /* Old endpoint in POSITION field. */
*op = DEV_IOCTL_S;
if(_MINIX_IOCTL_IOR(m_in.REQUEST)) access |= CPF_WRITE;
"cpf_grant_magic failed (ioctl)\n",
NO_NUM);
}
+ break;
+ case VFS_DEV_SELECT:
+ *op = DEV_SELECT;
+ break;
+ default:
+ panic(__FILE__,"safe_io_conversion: unknown operation",
+ *op);
}
/* If we have converted to a safe operation, I/O
&& (vp->v_mode & I_TYPE) != I_BLOCK_SPECIAL) return(ENOTTY);
dev = (dev_t) vp->v_sdev;
- return (dev_io(DEV_IOCTL, dev, who_e, m_in.ADDRESS, cvu64(0),
+ return (dev_io(VFS_DEV_IOCTL, dev, who_e, m_in.ADDRESS, cvu64(0),
m_in.REQUEST, f->filp_flags));
}
cum_io = 0;
}
- op = (rw_flag == READING ? DEV_READ : DEV_WRITE);
+ op = (rw_flag == READING ? VFS_DEV_READ : VFS_DEV_WRITE);
mode_word = vp->v_mode & I_TYPE;
regular = mode_word == I_REGULAR || mode_word == I_NAMED_PIPE;
while (bleft) {
/* First read the whole block */
- r = dev_bio(DEV_READ, dev, FS_PROC_NR, buf, b * _MIN_BLOCK_SIZE,
- _MIN_BLOCK_SIZE);
+ r = dev_bio(VFS_DEV_READ, dev, FS_PROC_NR, buf,
+ b * _MIN_BLOCK_SIZE, _MIN_BLOCK_SIZE);
if (r != _MIN_BLOCK_SIZE)
break;
{
int rops = *ops;
if (block) rops |= SEL_NOTIFY;
- *ops = dev_io(DEV_SELECT, f->filp_vno->v_sdev, rops, NULL, cvu64(0),
- 0, 0);
+ *ops = dev_io(VFS_DEV_SELECT, f->filp_vno->v_sdev, rops, NULL,
+ cvu64(0), 0, 0);
if (*ops < 0)
return SEL_ERR;
return SEL_OK;