Retired DEV_{READ,WRITE,GATHER,SCATTER,IOCTL} (safe versions *_S are to

be used and drivers should never receieve these 'unsafe' variants
any more).
This commit is contained in:
Ben Gras 2007-02-07 16:22:19 +00:00
parent 41e9fedf87
commit 8ea438ae93
25 changed files with 126 additions and 94 deletions

View file

@ -1051,7 +1051,7 @@ PRIVATE int w_io_test(void)
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)
@ -1142,21 +1142,21 @@ PRIVATE int do_transfer(struct wini *wn, unsigned int precomp,
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);
@ -1193,7 +1193,7 @@ PRIVATE int do_transfer(struct wini *wn, unsigned int precomp,
*===========================================================================*/
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 */
@ -1232,7 +1232,7 @@ int safe; /* iov contains addresses (0) or grants? */
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. */
@ -1254,7 +1254,7 @@ int safe; /* iov contains addresses (0) or grants? */
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.
@ -1355,7 +1355,7 @@ int safe; /* iov contains addresses (0) or grants? */
* 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. */
@ -1380,7 +1380,7 @@ int safe; /* iov contains addresses (0) or grants? */
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,
@ -2123,7 +2123,7 @@ void sense_request(void)
*===========================================================================*/
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 */
@ -2344,9 +2344,8 @@ int safe;
{
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) {

View file

@ -260,7 +260,7 @@ int safe; /* use safecopies? */
/* 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++) {
@ -294,7 +294,7 @@ int safe; /* use safecopies? */
/* 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;
@ -305,7 +305,7 @@ int safe; /* use safecopies? */
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;
@ -325,7 +325,7 @@ int safe; /* use safecopies? */
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++) {
@ -553,9 +553,8 @@ int safe;
{
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;

View file

@ -435,7 +435,7 @@ PRIVATE void f_cleanup()
*===========================================================================*/
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 */
@ -482,7 +482,7 @@ int safe;
/* 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);
@ -592,7 +592,7 @@ int safe;
}
}
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,
@ -619,7 +619,7 @@ int safe;
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,
@ -678,7 +678,7 @@ int safe;
* 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
@ -706,7 +706,7 @@ int opcode; /* DEV_GATHER or DEV_SCATTER */
*/
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));
@ -857,7 +857,7 @@ PRIVATE int seek()
* 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. */
@ -880,7 +880,7 @@ int opcode; /* DEV_GATHER or DEV_SCATTER */
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;
@ -1312,7 +1312,7 @@ int density;
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);

View file

@ -37,6 +37,7 @@
* driver_task: called by the device dependent task entry
*/
#include "../drivers.h"
#include <sys/ioc_disk.h>
#include <minix/mq.h>
@ -113,16 +114,22 @@ struct driver *dp; /* Device dependent entry points. */
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;
@ -212,8 +219,12 @@ int safe; /* use safecopies? */
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;
@ -272,8 +283,6 @@ int safe; /* use safecopies? */
/* 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);
@ -319,7 +328,10 @@ message *mp;
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);
}
}

View file

@ -164,7 +164,7 @@ struct part_entry *table; /* four entries */
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;

View file

@ -226,7 +226,7 @@ subread(struct logdevice *log, int count, int proc_nr,
*===========================================================================*/
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 */
@ -258,7 +258,7 @@ int safe; /* safe copies? */
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.

View file

@ -121,7 +121,7 @@ int device;
*===========================================================================*/
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 */
@ -158,7 +158,7 @@ int safe; /* safe copies */
/* 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. */
@ -169,7 +169,7 @@ int safe; /* safe copies */
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);
@ -201,7 +201,7 @@ int safe; /* safe copies */
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 {
@ -212,7 +212,7 @@ int safe; /* safe copies */
/* 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) {
@ -237,7 +237,7 @@ int safe; /* safe copies */
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);

View file

@ -140,7 +140,6 @@ PUBLIC void main(void)
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;

View file

@ -122,12 +122,12 @@ int safe; /* safe copies? */
/* 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,
@ -143,7 +143,7 @@ int safe; /* safe copies? */
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);

View file

@ -101,10 +101,14 @@ PUBLIC void main()
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 */
@ -226,7 +230,7 @@ message *m_ptr;
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();
@ -578,7 +582,7 @@ int count;
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 */
@ -596,7 +600,7 @@ int count;
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 */
@ -619,7 +623,7 @@ PRIVATE void dsp_setup()
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 */

View file

@ -71,7 +71,9 @@ message mess;
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;
}

View file

@ -810,8 +810,6 @@ PUBLIC void do_video(message *m)
break;
case DEV_IOCTL_S:
safe=1;
/* Fallthrough. */
case DEV_IOCTL:
if (m->TTY_REQUEST == MIOCMAP || m->TTY_REQUEST == MIOCUNMAP)
{
int r, do_map;

View file

@ -214,8 +214,6 @@ message *m;
break;
case DEV_READ_S:
safecopy = 1;
/* Fallthrough. */
case DEV_READ:
if (kbdp->req_size)
{
/* We handle only request at a time */
@ -263,8 +261,6 @@ message *m;
case DEV_WRITE_S:
safecopy = 1;
/* Fallthrough. */
case DEV_WRITE:
if (kbdp != &kbdaux)
{
printf("write to keyboard not implemented\n");
@ -316,8 +312,6 @@ message *m;
break;
case DEV_IOCTL_S:
safecopy=1;
/* Fallthrough. */
case DEV_IOCTL:
if (kbdp == &kbd && m->TTY_REQUEST == KIOCSLEDS)
{
kio_leds_t leds;

View file

@ -95,8 +95,6 @@ message *m_ptr;
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;
@ -146,8 +144,6 @@ message *m_ptr;
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;

View file

@ -259,8 +259,7 @@ PUBLIC void main(void)
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;
}
@ -282,11 +281,8 @@ PUBLIC void main(void)
/* 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;

View file

@ -145,13 +145,8 @@
#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 */

View file

@ -175,6 +175,7 @@ mq_t *m;
send_reply= 1;
free_mess= 1;
break;
#ifdef DEV_READ
case DEV_READ:
case DEV_WRITE:
case DEV_IOCTL3:
@ -183,6 +184,7 @@ mq_t *m;
send_reply= (result == SUSPEND);
free_mess= 0;
break;
#endif
case DEV_READ_S:
case DEV_WRITE_S:
case DEV_IOCTL_S:
@ -329,6 +331,7 @@ mq_t *m;
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;
@ -350,6 +353,7 @@ mq_t *m;
susp_flag= SFF_IOCTL_SUSP;
first_flag= SFF_IOCTL_FIRST;
break;
#endif
default:
ip_panic(("illegal case entry"));
}
@ -372,6 +376,7 @@ mq_t *m;
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);
@ -395,6 +400,7 @@ mq_t *m;
}
r= (*sr_fd->srf_ioctl)(sr_fd->srf_fd, request);
break;
#endif
default:
ip_panic(("illegal case entry"));
}
@ -933,8 +939,12 @@ assert (loc_fd->srf_flags & ip_flag);
}
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;
}
@ -1018,8 +1028,12 @@ int for_ioctl;
}
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;
}

View file

@ -268,7 +268,7 @@ int rw_flag; /* READING or WRITING */
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;
@ -373,7 +373,7 @@ int rw_flag; /* READING or WRITING */
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);

View file

@ -109,3 +109,10 @@
#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

View file

@ -90,10 +90,10 @@ vir_bytes bytes;
*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 :
@ -103,10 +103,11 @@ vir_bytes bytes;
}
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,
@ -174,7 +175,7 @@ int gids_size;
* 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 */

View file

@ -224,7 +224,7 @@ register struct super_block *sp; /* pointer to a superblock */
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");

View file

@ -108,3 +108,11 @@
#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

View file

@ -195,10 +195,10 @@ off_t *pos;
*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,
@ -208,10 +208,11 @@ off_t *pos;
}
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,
@ -240,7 +241,7 @@ off_t *pos;
/* 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;
@ -260,6 +261,13 @@ off_t *pos;
"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
@ -654,7 +662,7 @@ PUBLIC int do_ioctl()
&& (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));
}

View file

@ -108,7 +108,7 @@ int rw_flag; /* READING or WRITING */
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;
@ -279,8 +279,8 @@ int rw_flag; /* READING or WRITING */
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;

View file

@ -104,8 +104,8 @@ PRIVATE int select_request_general(struct filp *f, int *ops, int block)
{
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;