From: Ben Gras Date: Sun, 11 Sep 2005 17:09:11 +0000 (+0000) Subject: Andy's code fixes X-Git-Tag: v3.1.0~128 X-Git-Url: http://zhaoyanbai.com/repos/Bv9ARM.ch10.html?a=commitdiff_plain;h=e3709af1b8d357a68ceaa68ed74d626e2f78d927;p=minix.git Andy's code fixes --- diff --git a/drivers/at_wini/at_wini.c b/drivers/at_wini/at_wini.c index 1d504dd2b..34402e267 100644 --- a/drivers/at_wini/at_wini.c +++ b/drivers/at_wini/at_wini.c @@ -164,10 +164,10 @@ struct command { #define SUB_PER_DRIVE (NR_PARTITIONS * NR_PARTITIONS) #define NR_SUBDEVS (MAX_DRIVES * SUB_PER_DRIVE) #define DELAY_USECS 1000 /* controller timeout in microseconds */ -#define DELAY_TICKS 1 /* controller timeout in ticks */ +#define DELAY_TICKS 1 /* controller timeout in ticks */ #define DEF_TIMEOUT_TICKS 300 /* controller timeout in ticks */ -#define RECOVERY_USECS 500000 /* controller recovery time in microseconds */ -#define RECOVERY_TICKS 30 /* controller recovery time in ticks */ +#define RECOVERY_USECS 500000 /* controller recovery time in microseconds */ +#define RECOVERY_TICKS 30 /* controller recovery time in ticks */ #define INITIALIZED 0x01 /* drive is initialized */ #define DEAF 0x02 /* controller must be reset */ #define SMART 0x04 /* drive supports ATA commands */ @@ -231,37 +231,37 @@ PRIVATE int w_drive; /* selected drive */ PRIVATE int w_controller; /* selected controller */ PRIVATE struct device *w_dv; /* device's base and size */ -FORWARD _PROTOTYPE( void init_params, (void) ); +FORWARD _PROTOTYPE( void init_params, (void) ); FORWARD _PROTOTYPE( void init_drive, (struct wini *, int, int, int, int, int, int)); -FORWARD _PROTOTYPE( void init_params_pci, (int) ); -FORWARD _PROTOTYPE( int w_do_open, (struct driver *dp, message *m_ptr) ); -FORWARD _PROTOTYPE( struct device *w_prepare, (int dev) ); -FORWARD _PROTOTYPE( int w_identify, (void) ); -FORWARD _PROTOTYPE( char *w_name, (void) ); -FORWARD _PROTOTYPE( int w_specify, (void) ); -FORWARD _PROTOTYPE( int w_io_test, (void) ); +FORWARD _PROTOTYPE( void init_params_pci, (int) ); +FORWARD _PROTOTYPE( int w_do_open, (struct driver *dp, message *m_ptr) ); +FORWARD _PROTOTYPE( struct device *w_prepare, (int dev) ); +FORWARD _PROTOTYPE( int w_identify, (void) ); +FORWARD _PROTOTYPE( char *w_name, (void) ); +FORWARD _PROTOTYPE( int w_specify, (void) ); +FORWARD _PROTOTYPE( int w_io_test, (void) ); FORWARD _PROTOTYPE( int w_transfer, (int proc_nr, int opcode, off_t position, - iovec_t *iov, unsigned nr_req) ); -FORWARD _PROTOTYPE( int com_out, (struct command *cmd) ); -FORWARD _PROTOTYPE( void w_need_reset, (void) ); -FORWARD _PROTOTYPE( void ack_irqs, (unsigned int) ); + iovec_t *iov, unsigned nr_req) ); +FORWARD _PROTOTYPE( int com_out, (struct command *cmd) ); +FORWARD _PROTOTYPE( void w_need_reset, (void) ); +FORWARD _PROTOTYPE( void ack_irqs, (unsigned int) ); FORWARD _PROTOTYPE( int w_do_close, (struct driver *dp, message *m_ptr) ); -FORWARD _PROTOTYPE( int w_other, (struct driver *dp, message *m_ptr) ); -FORWARD _PROTOTYPE( int w_hw_int, (struct driver *dp, message *m_ptr) ); -FORWARD _PROTOTYPE( int com_simple, (struct command *cmd) ); -FORWARD _PROTOTYPE( void w_timeout, (void) ); -FORWARD _PROTOTYPE( int w_reset, (void) ); -FORWARD _PROTOTYPE( void w_intr_wait, (void) ); -FORWARD _PROTOTYPE( int at_intr_wait, (void) ); -FORWARD _PROTOTYPE( int w_waitfor, (int mask, int value) ); -FORWARD _PROTOTYPE( void w_geometry, (struct partition *entry) ); +FORWARD _PROTOTYPE( int w_other, (struct driver *dp, message *m_ptr) ); +FORWARD _PROTOTYPE( int w_hw_int, (struct driver *dp, message *m_ptr) ); +FORWARD _PROTOTYPE( int com_simple, (struct command *cmd) ); +FORWARD _PROTOTYPE( void w_timeout, (void) ); +FORWARD _PROTOTYPE( int w_reset, (void) ); +FORWARD _PROTOTYPE( void w_intr_wait, (void) ); +FORWARD _PROTOTYPE( int at_intr_wait, (void) ); +FORWARD _PROTOTYPE( int w_waitfor, (int mask, int value) ); +FORWARD _PROTOTYPE( void w_geometry, (struct partition *entry) ); #if ENABLE_ATAPI -FORWARD _PROTOTYPE( int atapi_sendpacket, (u8_t *packet, unsigned cnt) ); -FORWARD _PROTOTYPE( int atapi_intr_wait, (void) ); -FORWARD _PROTOTYPE( int atapi_open, (void) ); -FORWARD _PROTOTYPE( void atapi_close, (void) ); +FORWARD _PROTOTYPE( int atapi_sendpacket, (u8_t *packet, unsigned cnt) ); +FORWARD _PROTOTYPE( int atapi_intr_wait, (void) ); +FORWARD _PROTOTYPE( int atapi_open, (void) ); +FORWARD _PROTOTYPE( void atapi_close, (void) ); FORWARD _PROTOTYPE( int atapi_transfer, (int proc_nr, int opcode, - off_t position, iovec_t *iov, unsigned nr_req) ); + off_t position, iovec_t *iov, unsigned nr_req) ); #endif /* Entry points to this driver. */ @@ -293,9 +293,9 @@ PUBLIC int main() return(OK); } -/*============================================================================* - * init_params * - *============================================================================*/ +/*===========================================================================* + * init_params * + *===========================================================================*/ PRIVATE void init_params() { /* This routine is called at startup to initialize the drive parameters. */ @@ -314,7 +314,7 @@ PRIVATE void init_params() env_parse("ata_lba48", "d", 0, &w_lba48, 0, 1); env_parse("atapi_debug", "d", 0, &atapi_debug, 0, 1); - if(w_instance == 0) { + if (w_instance == 0) { /* Get the number of drives from the BIOS data area */ if ((s=sys_vircopy(SELF, BIOS_SEG, NR_HD_DRIVES_ADDR, SELF, D, (vir_bytes) params, NR_HD_DRIVES_SIZE)) != OK) @@ -355,7 +355,7 @@ PRIVATE void init_params() /* Look for controllers on the pci bus. Skip none the first instance, * skip one and then 2 for every instance, for every next instance. */ - if(w_instance == 0) + if (w_instance == 0) init_params_pci(0); else init_params_pci(w_instance*2-1); @@ -365,9 +365,9 @@ PRIVATE void init_params() #define ATA_IF_NOTCOMPAT1 (1L << 0) #define ATA_IF_NOTCOMPAT2 (1L << 2) -/*============================================================================* - * init_drive * - *============================================================================*/ +/*===========================================================================* + * init_drive * + *===========================================================================*/ PRIVATE void init_drive(struct wini *w, int base_cmd, int base_ctl, int irq, int ack, int hook, int drive) { w->state = 0; @@ -383,9 +383,9 @@ PRIVATE void init_drive(struct wini *w, int base_cmd, int base_ctl, int irq, int w->lba48 = 0; } -/*============================================================================* - * init_params_pci * - *============================================================================*/ +/*===========================================================================* + * init_params_pci * + *===========================================================================*/ PRIVATE void init_params_pci(int skip) { int r, devind, drive; @@ -399,7 +399,7 @@ PRIVATE void init_params_pci(int skip) /* Base class must be 01h (mass storage), subclass must * be 01h (ATA). */ - if(pci_attr_r8(devind, PCI_BCR) != 0x01 || + if (pci_attr_r8(devind, PCI_BCR) != 0x01 || pci_attr_r8(devind, PCI_SCR) != 0x01) { continue; } @@ -410,11 +410,11 @@ PRIVATE void init_params_pci(int skip) irq = pci_attr_r8(devind, PCI_ILR); /* Any non-compat drives? */ - if(interface & (ATA_IF_NOTCOMPAT1 | ATA_IF_NOTCOMPAT2)) { + if (interface & (ATA_IF_NOTCOMPAT1 | ATA_IF_NOTCOMPAT2)) { int s; irq_hook = irq; - if(skip > 0) { - if(w_pci_debug) printf("atapci skipping controller (remain %d)\n", skip); + if (skip > 0) { + if (w_pci_debug) printf("atapci skipping controller (remain %d)\n", skip); skip--; continue; } @@ -430,36 +430,36 @@ PRIVATE void init_params_pci(int skip) /* If not.. this is not the ata-pci controller we're * looking for. */ - if(w_pci_debug) printf("atapci skipping compatability controller\n"); + if (w_pci_debug) printf("atapci skipping compatability controller\n"); continue; } /* Primary channel not in compatability mode? */ - if(interface & ATA_IF_NOTCOMPAT1) { + if (interface & ATA_IF_NOTCOMPAT1) { u32_t base_cmd, base_ctl; base_cmd = pci_attr_r32(devind, PCI_BAR) & 0xffffffe0; base_ctl = pci_attr_r32(devind, PCI_BAR_2) & 0xffffffe0; - if(base_cmd != REG_CMD_BASE0 && base_cmd != REG_CMD_BASE1) { + if (base_cmd != REG_CMD_BASE0 && base_cmd != REG_CMD_BASE1) { init_drive(&wini[w_next_drive], base_cmd, base_ctl, irq, 1, irq_hook, 0); init_drive(&wini[w_next_drive+1], base_cmd, base_ctl, irq, 1, irq_hook, 1); - if(w_pci_debug) + if (w_pci_debug) printf("atapci %d: 0x%x 0x%x irq %d\n", devind, base_cmd, base_ctl, irq); } else printf("atapci: ignored drives on primary channel, base %x\n", base_cmd); } /* Secondary channel not in compatability mode? */ - if(interface & ATA_IF_NOTCOMPAT2) { + if (interface & ATA_IF_NOTCOMPAT2) { u32_t base_cmd, base_ctl; base_cmd = pci_attr_r32(devind, PCI_BAR_3) & 0xffffffe0; base_ctl = pci_attr_r32(devind, PCI_BAR_4) & 0xffffffe0; - if(base_cmd != REG_CMD_BASE0 && base_cmd != REG_CMD_BASE1) { + if (base_cmd != REG_CMD_BASE0 && base_cmd != REG_CMD_BASE1) { init_drive(&wini[w_next_drive+2], base_cmd, base_ctl, irq, 1, irq_hook, 2); init_drive(&wini[w_next_drive+3], base_cmd, base_ctl, irq, 1, irq_hook, 3); - if(w_pci_debug) + if (w_pci_debug) printf("atapci %d: 0x%x 0x%x irq %d\n", devind, base_cmd, base_ctl, irq); } else printf("atapci: ignored drives on secondary channel, base %x\n", base_cmd); } @@ -467,9 +467,9 @@ PRIVATE void init_params_pci(int skip) } } -/*============================================================================* - * w_do_open * - *============================================================================*/ +/*===========================================================================* + * w_do_open * + *===========================================================================*/ PRIVATE int w_do_open(dp, m_ptr) struct driver *dp; message *m_ptr; @@ -503,7 +503,7 @@ message *m_ptr; * due to no CD being in the drive). If it fails, ignore * the device forever. */ - if(!(wn->state & ATAPI) && w_io_test() != OK) { + if (!(wn->state & ATAPI) && w_io_test() != OK) { wn->state |= IGNORING; return(ENXIO); } @@ -618,9 +618,9 @@ PRIVATE int w_identify() wn->ldhpref |= LDH_LBA; size = id_longword(60); - if(w_lba48 && ((id_word(83)) & (1L << 10))) { + if (w_lba48 && ((id_word(83)) & (1L << 10))) { /* Drive is LBA48 capable (and LBA48 is turned on). */ - if(id_word(102) || id_word(103)) { + if (id_word(102) || id_word(103)) { /* If no. of sectors doesn't fit in 32 bits, * trunacte to this. So it's LBA32 for now. * This can still address devices up to 2TB @@ -680,7 +680,7 @@ PRIVATE int w_identify() return(ERR); } - if(wn->irq == NO_IRQ) { + if (wn->irq == NO_IRQ) { /* Everything looks OK; register IRQ so we can stop polling. */ wn->irq = w_drive < 2 ? AT_WINI_0_IRQ : AT_WINI_1_IRQ; wn->irq_hook_id = wn->irq; /* id to be returned if interrupt occurs */ @@ -728,7 +728,7 @@ PRIVATE int w_io_test(void) save_errors = max_errors; save_wakeup = wakeup_ticks; - if(!w_standard_timeouts) { + if (!w_standard_timeouts) { timeout_ticks = HZ * 4; wakeup_ticks = HZ * 6; max_errors = 3; @@ -737,13 +737,13 @@ PRIVATE int w_io_test(void) w_testing = 1; /* Try I/O on the actual drive (not any (sub)partition). */ - if(w_prepare(w_drive * DEV_PER_DRIVE) == NIL_DEV) + 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, 0, &iov, 1); /* Switch back. */ - if(w_prepare(save_dev) == NIL_DEV) + if (w_prepare(save_dev) == NIL_DEV) panic(w_name(), "Couldn't switch back devices", NO_NUM); /* Restore parameters. */ @@ -753,7 +753,7 @@ PRIVATE int w_io_test(void) w_testing = 0; /* Test if everything worked. */ - if(r != OK || iov.iov_size != 0) { + if (r != OK || iov.iov_size != 0) { return ERR; } @@ -942,9 +942,9 @@ unsigned nr_req; /* length of request vector */ return(OK); } -/*============================================================================* - * com_out * - *============================================================================*/ +/*===========================================================================* + * com_out * + *===========================================================================*/ PRIVATE int com_out(cmd) struct command *cmd; /* Command block */ { @@ -956,7 +956,7 @@ struct command *cmd; /* Command block */ pvb_pair_t outbyte[7]; /* vector for sys_voutb() */ int s; /* status for sys_(v)outb() */ - if(w_wn->state & IGNORING) return ERR; + if (w_wn->state & IGNORING) return ERR; if (!w_waitfor(STATUS_BSY, 0)) { printf("%s: controller not ready\n", w_name()); @@ -1011,9 +1011,9 @@ PRIVATE void w_need_reset() } } -/*============================================================================* - * w_do_close * - *============================================================================*/ +/*===========================================================================* + * w_do_close * + *===========================================================================*/ PRIVATE int w_do_close(dp, m_ptr) struct driver *dp; message *m_ptr; @@ -1028,16 +1028,16 @@ message *m_ptr; return(OK); } -/*============================================================================* - * com_simple * - *============================================================================*/ +/*===========================================================================* + * com_simple * + *===========================================================================*/ PRIVATE int com_simple(cmd) struct command *cmd; /* Command block */ { /* A simple controller command, only one interrupt and no data-out phase. */ int r; - if(w_wn->state & IGNORING) return ERR; + if (w_wn->state & IGNORING) return ERR; if ((r = com_out(cmd)) == OK) r = at_intr_wait(); w_command = CMD_IDLE; @@ -1067,8 +1067,8 @@ PRIVATE void w_timeout(void) /*FALL THROUGH*/ default: /* Some other command. */ - if(w_testing) wn->state |= IGNORING; /* Kick out this drive. */ - else if(!w_silent) printf("%s: timeout on command %02x\n", w_name(), w_command); + if (w_testing) wn->state |= IGNORING; /* Kick out this drive. */ + else if (!w_silent) printf("%s: timeout on command %02x\n", w_name(), w_command); w_need_reset(); wn->w_status = 0; } @@ -1086,7 +1086,7 @@ PRIVATE int w_reset() struct wini *wn = w_wn; /* Don't bother if this drive is forgotten. */ - if(w_wn->state & IGNORING) return ERR; + if (w_wn->state & IGNORING) return ERR; /* Wait for any internal drive recovery. */ tickdelay(RECOVERY_TICKS); @@ -1121,9 +1121,9 @@ PRIVATE int w_reset() return(OK); } -/*============================================================================* - * w_intr_wait * - *============================================================================*/ +/*===========================================================================* + * w_intr_wait * + *===========================================================================*/ PRIVATE void w_intr_wait() { /* Wait for a task completion interrupt. */ @@ -1150,9 +1150,9 @@ PRIVATE void w_intr_wait() } } -/*============================================================================* - * at_intr_wait * - *============================================================================*/ +/*===========================================================================* + * at_intr_wait * + *===========================================================================*/ PRIVATE int at_intr_wait() { /* Wait for an interrupt, study the status bits and return error/success. */ @@ -1175,9 +1175,9 @@ PRIVATE int at_intr_wait() return(r); } -/*==========================================================================* - * w_waitfor * - *==========================================================================*/ +/*===========================================================================* + * w_waitfor * + *===========================================================================*/ PRIVATE int w_waitfor(mask, value) int mask; /* status mask */ int value; /* required status */ @@ -1203,9 +1203,9 @@ int value; /* required status */ return(0); } -/*============================================================================* - * w_geometry * - *============================================================================*/ +/*===========================================================================* + * w_geometry * + *===========================================================================*/ PRIVATE void w_geometry(entry) struct partition *entry; { @@ -1264,7 +1264,7 @@ void sense_request(void) for(i = 0; i < SENSE_PACKETSIZE; i++) sense[i] = 0xff; r = atapi_sendpacket(packet, SENSE_PACKETSIZE); if (r != OK) { printf("request sense command failed\n"); return; } - if(atapi_intr_wait() <= 0) { printf("WARNING: request response failed\n"); } + if (atapi_intr_wait() <= 0) { printf("WARNING: request response failed\n"); } if (sys_insw(w_wn->base_cmd + REG_DATA, SELF, (void *) sense, SENSE_PACKETSIZE) != OK) printf("WARNING: sense reading failed\n"); @@ -1394,13 +1394,13 @@ unsigned nr_req; /* length of request vector */ if (r < 0) { err: /* Don't retry if too many errors. */ - if(atapi_debug) sense_request(); + if (atapi_debug) sense_request(); if (++errors == max_errors) { w_command = CMD_IDLE; - if(atapi_debug) printf("giving up (%d)\n", errors); + if (atapi_debug) printf("giving up (%d)\n", errors); return(EIO); } - if(atapi_debug) printf("retry (%d)\n", errors); + if (atapi_debug) printf("retry (%d)\n", errors); } } @@ -1420,7 +1420,7 @@ unsigned cnt; pvb_pair_t outbyte[6]; /* vector for sys_voutb() */ int s; - if(wn->state & IGNORING) return ERR; + if (wn->state & IGNORING) return ERR; /* Select Master/Slave drive */ if ((s=sys_outb(wn->base_cmd + REG_DRIVE, wn->ldhpref)) != OK) @@ -1450,7 +1450,7 @@ unsigned cnt; pv_set(outbyte[3], wn->base_cmd + REG_CNT_LO, (cnt >> 0) & 0xFF); pv_set(outbyte[4], wn->base_cmd + REG_CNT_HI, (cnt >> 8) & 0xFF); pv_set(outbyte[5], wn->base_cmd + REG_COMMAND, w_command); - if(atapi_debug) printf("cmd: %x ", w_command); + if (atapi_debug) printf("cmd: %x ", w_command); if ((s=sys_voutb(outbyte,6)) != OK) panic(w_name(),"Couldn't write registers with sys_voutb()",s); @@ -1466,7 +1466,7 @@ unsigned cnt; { int p; - if(atapi_debug) { + if (atapi_debug) { printf("sent command:"); for(p = 0; p < ATAPI_PACKETSIZE; p++) { printf(" %02x", packet[p]); } printf("\n"); @@ -1475,36 +1475,36 @@ unsigned cnt; return(OK); } -/*============================================================================* - * w_other * - *============================================================================*/ +/*===========================================================================* + * w_other * + *===========================================================================*/ PRIVATE int w_other(dr, m) struct driver *dr; message *m; { int r, timeout, prev; - if(m->m_type != DEV_IOCTL ) { + if (m->m_type != DEV_IOCTL ) { return EINVAL; } - if(m->REQUEST == DIOCTIMEOUT) { - if((r=sys_datacopy(m->PROC_NR, (vir_bytes)m->ADDRESS, + if (m->REQUEST == DIOCTIMEOUT) { + if ((r=sys_datacopy(m->PROC_NR, (vir_bytes)m->ADDRESS, SELF, (vir_bytes)&timeout, sizeof(timeout))) != OK) return r; - if(timeout == 0) { + if (timeout == 0) { /* Restore defaults. */ timeout_ticks = DEF_TIMEOUT_TICKS; max_errors = MAX_ERRORS; wakeup_ticks = WAKEUP; w_silent = 0; - } else if(timeout < 0) { + } else if (timeout < 0) { return EINVAL; } else { prev = wakeup_ticks; - if(!w_standard_timeouts) { + if (!w_standard_timeouts) { /* Set (lower) timeout, lower error * tolerance and set silent mode. */ @@ -1512,21 +1512,21 @@ message *m; max_errors = 3; w_silent = 1; - if(timeout_ticks > timeout) + if (timeout_ticks > timeout) timeout_ticks = timeout; } - if((r=sys_datacopy(SELF, (vir_bytes)&prev, + if ((r=sys_datacopy(SELF, (vir_bytes)&prev, m->PROC_NR, (vir_bytes)m->ADDRESS, sizeof(prev))) != OK) return r; } return OK; - } else if(m->REQUEST == DIOCOPENCT) { + } else if (m->REQUEST == DIOCOPENCT) { int count; - if(w_prepare(m->DEVICE) == NIL_DEV) return ENXIO; + if (w_prepare(m->DEVICE) == NIL_DEV) return ENXIO; count = w_wn->open_ct; - if((r=sys_datacopy(SELF, (vir_bytes)&count, + if ((r=sys_datacopy(SELF, (vir_bytes)&count, m->PROC_NR, (vir_bytes)m->ADDRESS, sizeof(count))) != OK) return r; return OK; @@ -1535,9 +1535,9 @@ message *m; } -/*============================================================================* - * w_hw_int * - *============================================================================*/ +/*===========================================================================* + * w_hw_int * + *===========================================================================*/ PRIVATE int w_hw_int(dr, m) struct driver *dr; message *m; @@ -1549,16 +1549,16 @@ message *m; } -/*============================================================================* - * ack_irqs * - *============================================================================*/ +/*===========================================================================* + * ack_irqs * + *===========================================================================*/ PRIVATE void ack_irqs(unsigned int irqs) { unsigned int drive; for (drive = 0; drive < MAX_DRIVES && irqs; drive++) { - if(!(wini[drive].state & IGNORING) && wini[drive].irq_need_ack && + if (!(wini[drive].state & IGNORING) && wini[drive].irq_need_ack && (wini[drive].irq_mask & irqs)) { - if(sys_inb((wini[drive].base_cmd + REG_STATUS), &wini[drive].w_status) != OK) + if (sys_inb((wini[drive].base_cmd + REG_STATUS), &wini[drive].w_status) != OK) printf("couldn't ack irq on drive %d\n", drive); if (sys_irqenable(&wini[drive].irq_hook_id) != OK) printf("couldn't re-enable drive %d\n", drive); @@ -1568,8 +1568,8 @@ PRIVATE void ack_irqs(unsigned int irqs) } -#define STSTR(a) if(status & STATUS_ ## a) { strcat(str, #a); strcat(str, " "); } -#define ERRSTR(a) if(e & ERROR_ ## a) { strcat(str, #a); strcat(str, " "); } +#define STSTR(a) if (status & STATUS_ ## a) { strcat(str, #a); strcat(str, " "); } +#define ERRSTR(a) if (e & ERROR_ ## a) { strcat(str, #a); strcat(str, " "); } char *strstatus(int status) { static char str[200]; @@ -1600,9 +1600,9 @@ char *strerr(int e) return str; } -/*============================================================================* - * atapi_intr_wait * - *============================================================================*/ +/*===========================================================================* + * atapi_intr_wait * + *===========================================================================*/ PRIVATE int atapi_intr_wait() { /* Wait for an interrupt and study the results. Returns a number of bytes @@ -1635,7 +1635,7 @@ PRIVATE int atapi_intr_wait() printf("wn %p S=%x=%s E=%02x=%s L=%04x I=%02x\n", wn, wn->w_status, strstatus(wn->w_status), e, strerr(e), len, irr); #endif if (wn->w_status & (STATUS_BSY | STATUS_CHECK)) { - if(atapi_debug) { + if (atapi_debug) { printf("atapi fail: S=%x=%s E=%02x=%s L=%04x I=%02x\n", wn->w_status, strstatus(wn->w_status), e, strerr(e), len, irr); } return ERR; diff --git a/drivers/at_wini/at_wini.h b/drivers/at_wini/at_wini.h index 33a77119a..b9d57aabd 100644 --- a/drivers/at_wini/at_wini.h +++ b/drivers/at_wini/at_wini.h @@ -4,5 +4,5 @@ _PROTOTYPE(int main, (void)); -#define VERBOSE 0 /* display identify messages during boot */ -#define ENABLE_ATAPI 1 /* add ATAPI cd-rom support to driver */ +#define VERBOSE 0 /* display identify messages during boot */ +#define ENABLE_ATAPI 1 /* add ATAPI cd-rom support to driver */ diff --git a/drivers/floppy/floppy.c b/drivers/floppy/floppy.c index a906673a7..f18d90853 100644 --- a/drivers/floppy/floppy.c +++ b/drivers/floppy/floppy.c @@ -6,6 +6,7 @@ * floppy_task: main entry when system is brought up * * Changes: + * Sep 11, 2005 code cleanup (Andy Tanenbaum) * Dec 01, 2004 floppy driver moved to user-space (Jorrit N. Herder) * Sep 15, 2004 sync alarms/ local timer management (Jorrit N. Herder) * Aug 12, 2003 null seek no interrupt fix (Mike Haertel) @@ -239,30 +240,30 @@ PRIVATE timer_t *f_timers; /* queue of floppy timers */ PRIVATE clock_t f_next_timeout; /* the next timeout time */ FORWARD _PROTOTYPE( void f_expire_tmrs, (struct driver *dp, message *m_ptr) ); FORWARD _PROTOTYPE( void f_set_timer, (timer_t *tp, clock_t delta, - tmr_func_t watchdog) ); -FORWARD _PROTOTYPE( void stop_motor, (timer_t *tp) ); -FORWARD _PROTOTYPE( void f_timeout, (timer_t *tp) ); + tmr_func_t watchdog) ); +FORWARD _PROTOTYPE( void stop_motor, (timer_t *tp) ); +FORWARD _PROTOTYPE( void f_timeout, (timer_t *tp) ); -FORWARD _PROTOTYPE( struct device *f_prepare, (int device) ); -FORWARD _PROTOTYPE( char *f_name, (void) ); -FORWARD _PROTOTYPE( void f_cleanup, (void) ); +FORWARD _PROTOTYPE( struct device *f_prepare, (int device) ); +FORWARD _PROTOTYPE( char *f_name, (void) ); +FORWARD _PROTOTYPE( void f_cleanup, (void) ); FORWARD _PROTOTYPE( int f_transfer, (int proc_nr, int opcode, off_t position, - iovec_t *iov, unsigned nr_req) ); -FORWARD _PROTOTYPE( int dma_setup, (int opcode) ); -FORWARD _PROTOTYPE( void start_motor, (void) ); -FORWARD _PROTOTYPE( int seek, (void) ); -FORWARD _PROTOTYPE( int fdc_transfer, (int opcode) ); -FORWARD _PROTOTYPE( int fdc_results, (void) ); -FORWARD _PROTOTYPE( int fdc_command, (u8_t *cmd, int len) ); -FORWARD _PROTOTYPE( void fdc_out, (int val) ); -FORWARD _PROTOTYPE( int recalibrate, (void) ); -FORWARD _PROTOTYPE( void f_reset, (void) ); -FORWARD _PROTOTYPE( int f_intr_wait, (void) ); -FORWARD _PROTOTYPE( int read_id, (void) ); -FORWARD _PROTOTYPE( int f_do_open, (struct driver *dp, message *m_ptr) ); -FORWARD _PROTOTYPE( void floppy_stop, (struct driver *dp, message *m_ptr) ); -FORWARD _PROTOTYPE( int test_read, (int density) ); -FORWARD _PROTOTYPE( void f_geometry, (struct partition *entry)); + iovec_t *iov, unsigned nr_req) ); +FORWARD _PROTOTYPE( int dma_setup, (int opcode) ); +FORWARD _PROTOTYPE( void start_motor, (void) ); +FORWARD _PROTOTYPE( int seek, (void) ); +FORWARD _PROTOTYPE( int fdc_transfer, (int opcode) ); +FORWARD _PROTOTYPE( int fdc_results, (void) ); +FORWARD _PROTOTYPE( int fdc_command, (u8_t *cmd, int len) ); +FORWARD _PROTOTYPE( void fdc_out, (int val) ); +FORWARD _PROTOTYPE( int recalibrate, (void) ); +FORWARD _PROTOTYPE( void f_reset, (void) ); +FORWARD _PROTOTYPE( int f_intr_wait, (void) ); +FORWARD _PROTOTYPE( int read_id, (void) ); +FORWARD _PROTOTYPE( int f_do_open, (struct driver *dp, message *m_ptr) ); +FORWARD _PROTOTYPE( void floppy_stop, (struct driver *dp, message *m_ptr)); +FORWARD _PROTOTYPE( int test_read, (int density) ); +FORWARD _PROTOTYPE( void f_geometry, (struct partition *entry) ); /* Entry points to this driver. */ PRIVATE struct driver f_dtab = { @@ -561,7 +562,7 @@ unsigned nr_req; /* length of request vector */ if (r == OK && opcode == DEV_SCATTER) { /* Copy the user bytes to the DMA buffer. */ - if((s=sys_datacopy(proc_nr, *up, SELF, + if ((s=sys_datacopy(proc_nr, *up, SELF, (vir_bytes) tmp_buf, (phys_bytes) SECTOR_SIZE)) != OK) panic("FLOPPY", "Sys_vircopy failed", s); @@ -581,7 +582,7 @@ unsigned nr_req; /* length of request vector */ if (r == OK && opcode == DEV_GATHER) { /* Copy the DMA buffer to user space. */ - if((s=sys_datacopy(SELF, (vir_bytes) tmp_buf, + if ((s=sys_datacopy(SELF, (vir_bytes) tmp_buf, proc_nr, *up, (phys_bytes) SECTOR_SIZE)) != OK) panic("FLOPPY", "Sys_vircopy failed", s); @@ -875,9 +876,9 @@ int opcode; /* DEV_GATHER or DEV_SCATTER */ return(OK); } -/*==========================================================================* - * fdc_results * - *==========================================================================*/ +/*===========================================================================* + * fdc_results * + *===========================================================================*/ PRIVATE int fdc_results() { /* Extract results from the controller after an operation, then allow floppy @@ -1137,9 +1138,9 @@ timer_t *tp; } } -/*==========================================================================* - * read_id * - *==========================================================================*/ +/*===========================================================================* + * read_id * + *===========================================================================*/ PRIVATE int read_id() { /* Determine current cylinder and sector. */ @@ -1170,9 +1171,9 @@ PRIVATE int read_id() return(OK); } -/*==========================================================================* - * f_do_open * - *==========================================================================*/ +/*===========================================================================* + * f_do_open * + *===========================================================================*/ PRIVATE int f_do_open(dp, m_ptr) struct driver *dp; message *m_ptr; /* pointer to open message */ @@ -1231,9 +1232,9 @@ message *m_ptr; /* pointer to open message */ return(EIO); /* nothing worked */ } -/*==========================================================================* - * test_read * - *==========================================================================*/ +/*===========================================================================* + * test_read * + *===========================================================================*/ PRIVATE int test_read(density) int density; { @@ -1261,9 +1262,9 @@ int density; return(OK); } -/*============================================================================* - * f_geometry * - *============================================================================*/ +/*===========================================================================* + * f_geometry * + *===========================================================================*/ PRIVATE void f_geometry(entry) struct partition *entry; { diff --git a/drivers/memory/memory.c b/drivers/memory/memory.c index 611010173..bac418040 100644 --- a/drivers/memory/memory.c +++ b/drivers/memory/memory.c @@ -33,14 +33,14 @@ PRIVATE struct machine machine; /* machine information */ extern int errno; /* error number for PM calls */ -FORWARD _PROTOTYPE( char *m_name, (void) ); -FORWARD _PROTOTYPE( struct device *m_prepare, (int device) ); +FORWARD _PROTOTYPE( char *m_name, (void) ); +FORWARD _PROTOTYPE( struct device *m_prepare, (int device) ); FORWARD _PROTOTYPE( int m_transfer, (int proc_nr, int opcode, off_t position, - iovec_t *iov, unsigned nr_req) ); -FORWARD _PROTOTYPE( int m_do_open, (struct driver *dp, message *m_ptr) ); + iovec_t *iov, unsigned nr_req) ); +FORWARD _PROTOTYPE( int m_do_open, (struct driver *dp, message *m_ptr) ); FORWARD _PROTOTYPE( void m_init, (void) ); -FORWARD _PROTOTYPE( int m_ioctl, (struct driver *dp, message *m_ptr) ); -FORWARD _PROTOTYPE( void m_geometry, (struct partition *entry) ); +FORWARD _PROTOTYPE( int m_ioctl, (struct driver *dp, message *m_ptr) ); +FORWARD _PROTOTYPE( void m_geometry, (struct partition *entry) ); /* Entry points to this driver. */ PRIVATE struct driver m_dtab = { @@ -196,9 +196,9 @@ unsigned nr_req; /* length of request vector */ return(OK); } -/*============================================================================* - * m_do_open * - *============================================================================*/ +/*===========================================================================* + * m_do_open * + *===========================================================================*/ PRIVATE int m_do_open(dp, m_ptr) struct driver *dp; message *m_ptr; @@ -317,9 +317,9 @@ message *m_ptr; /* pointer to control message */ return(OK); } -/*============================================================================* - * m_geometry * - *============================================================================*/ +/*===========================================================================* + * m_geometry * + *===========================================================================*/ PRIVATE void m_geometry(entry) struct partition *entry; { diff --git a/drivers/tty/console.c b/drivers/tty/console.c index 44c672eea..1f6496a6e 100644 --- a/drivers/tty/console.c +++ b/drivers/tty/console.c @@ -115,7 +115,7 @@ struct sequence { unsigned char value; }; -FORWARD _PROTOTYPE( int cons_write, (struct tty *tp, int try) ); +FORWARD _PROTOTYPE( int cons_write, (struct tty *tp, int try) ); FORWARD _PROTOTYPE( void cons_echo, (tty_t *tp, int c) ); FORWARD _PROTOTYPE( void out_char, (console_t *cons, int c) ); FORWARD _PROTOTYPE( void putk, (int c) ); @@ -126,7 +126,7 @@ FORWARD _PROTOTYPE( void parse_escape, (console_t *cons, int c) ); FORWARD _PROTOTYPE( void scroll_screen, (console_t *cons, int dir) ); FORWARD _PROTOTYPE( void set_6845, (int reg, unsigned val) ); FORWARD _PROTOTYPE( void get_6845, (int reg, unsigned *val) ); -FORWARD _PROTOTYPE( void stop_beep, (timer_t *tmrp) ); +FORWARD _PROTOTYPE( void stop_beep, (timer_t *tmrp) ); FORWARD _PROTOTYPE( void cons_org0, (void) ); FORWARD _PROTOTYPE( int ga_program, (struct sequence *seq) ); FORWARD _PROTOTYPE( int cons_ioctl, (tty_t *tp, int) ); @@ -149,7 +149,7 @@ int try; char buf[64]; console_t *cons = tp->tty_priv; - if(try) return 1; /* we can always write to console */ + if (try) return 1; /* we can always write to console */ /* Check quickly for nothing to do, so this can be called often without * unmodular tests elsewhere. @@ -853,7 +853,7 @@ tty_t *tp; cons->c_cur = cons->c_org = cons->c_start; cons->c_attr = cons->c_blank = BLANK_COLOR; - if(line != 0) { + if (line != 0) { /* Clear the non-console vtys. */ blank_color = BLANK_COLOR; mem_vid_copy(BLANK_MEM, cons->c_start, scr_size); @@ -870,18 +870,18 @@ tty_t *tp; cons_ioctl(tp, 0); } -/*==========================================================================* - * kputc * - *==========================================================================*/ +/*===========================================================================* + * kputc * + *===========================================================================*/ PUBLIC void kputc(c) int c; { putk(c); } -/*==========================================================================* - * do_new_kmess * - *==========================================================================*/ +/*===========================================================================* + * do_new_kmess * + *===========================================================================*/ PUBLIC void do_new_kmess(m) message *m; { @@ -928,9 +928,9 @@ message *m; prev_next = kmess.km_next; } -/*==========================================================================* - * do_diagnostics * - *==========================================================================*/ +/*===========================================================================* + * do_diagnostics * + *===========================================================================*/ PUBLIC void do_diagnostics(m_ptr) message *m_ptr; /* pointer to request message */ { diff --git a/drivers/tty/keyboard.c b/drivers/tty/keyboard.c index ef9639864..c37fa25e7 100644 --- a/drivers/tty/keyboard.c +++ b/drivers/tty/keyboard.c @@ -81,15 +81,15 @@ typedef struct observer { int proc_nr; int events; } obs_t; PRIVATE obs_t fkey_obs[12]; /* observers for F1-F12 */ PRIVATE obs_t sfkey_obs[12]; /* observers for SHIFT F1-F12 */ -FORWARD _PROTOTYPE( int kb_ack, (void) ); -FORWARD _PROTOTYPE( int kb_wait, (void) ); -FORWARD _PROTOTYPE( int func_key, (int scode) ); -FORWARD _PROTOTYPE( int scan_keyboard, (void) ); -FORWARD _PROTOTYPE( unsigned make_break, (int scode) ); -FORWARD _PROTOTYPE( void set_leds, (void) ); -FORWARD _PROTOTYPE( void show_key_mappings, (void) ); -FORWARD _PROTOTYPE( int kb_read, (struct tty *tp, int try) ); -FORWARD _PROTOTYPE( unsigned map_key, (int scode) ); +FORWARD _PROTOTYPE( int kb_ack, (void) ); +FORWARD _PROTOTYPE( int kb_wait, (void) ); +FORWARD _PROTOTYPE( int func_key, (int scode) ); +FORWARD _PROTOTYPE( int scan_keyboard, (void) ); +FORWARD _PROTOTYPE( unsigned make_break, (int scode) ); +FORWARD _PROTOTYPE( void set_leds, (void) ); +FORWARD _PROTOTYPE( void show_key_mappings, (void) ); +FORWARD _PROTOTYPE( int kb_read, (struct tty *tp, int try) ); +FORWARD _PROTOTYPE( unsigned map_key, (int scode) ); /*===========================================================================* * map_key0 * @@ -149,15 +149,15 @@ message *m_ptr; if (ihead == ibuf + KB_IN_BYTES) ihead = ibuf; icount++; tty_table[ccurrent].tty_events = 1; - if(tty_table[ccurrent].tty_select_ops & SEL_RD) { + if (tty_table[ccurrent].tty_select_ops & SEL_RD) { select_retry(&tty_table[ccurrent]); } } } -/*==========================================================================* - * kb_read * - *==========================================================================*/ +/*===========================================================================* + * kb_read * + *===========================================================================*/ PRIVATE int kb_read(tp, try) tty_t *tp; int try; @@ -169,9 +169,9 @@ int try; tp = &tty_table[ccurrent]; /* always use the current console */ - if(try) { + if (try) { printf("tty: kb: try: %d icount: %d\n", try, icount); - if(icount > 0) return 1; + if (icount > 0) return 1; return 0; } @@ -326,9 +326,9 @@ PRIVATE void set_leds() kb_ack(); /* wait for ack response */ } -/*==========================================================================* - * kb_wait * - *==========================================================================*/ +/*===========================================================================* + * kb_wait * + *===========================================================================*/ PRIVATE int kb_wait() { /* Wait until the controller is ready; return zero if this times out. */ @@ -348,9 +348,9 @@ PRIVATE int kb_wait() return(retries); /* zero on timeout, positive if ready */ } -/*==========================================================================* - * kb_ack * - *==========================================================================*/ +/*===========================================================================* + * kb_ack * + *===========================================================================*/ PRIVATE int kb_ack() { /* Wait until kbd acknowledges last command; return zero if this times out. */ @@ -380,7 +380,7 @@ tty_t *tp; } /*===========================================================================* - * kb_init_once * + * kb_init_once * *===========================================================================*/ PUBLIC void kb_init_once(void) { @@ -559,9 +559,9 @@ int scode; /* scan code for a function key */ return(TRUE); } -/*==========================================================================* - * show_key_mappings * - *==========================================================================*/ +/*===========================================================================* + * show_key_mappings * + *===========================================================================*/ PRIVATE void show_key_mappings() { int i,s; @@ -596,9 +596,9 @@ PRIVATE void show_key_mappings() printf("\n"); } -/*==========================================================================* - * scan_keyboard * - *==========================================================================*/ +/*===========================================================================* + * scan_keyboard * + *===========================================================================*/ PRIVATE int scan_keyboard() { /* Fetch the character from the keyboard hardware and acknowledge it. */ @@ -615,9 +615,9 @@ PRIVATE int scan_keyboard() return(byte_in[0].value); /* return scan code */ } -/*==========================================================================* - * do_panic_dumps * - *==========================================================================*/ +/*===========================================================================* + * do_panic_dumps * + *===========================================================================*/ PUBLIC void do_panic_dumps(m) message *m; /* request message to TTY */ { diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index b3c2c3440..74dc94a1a 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c @@ -65,7 +65,7 @@ typedef struct pty { PRIVATE pty_t pty_table[NR_PTYS]; /* PTY bookkeeping */ -FORWARD _PROTOTYPE( int pty_write, (tty_t *tp, int try) ); +FORWARD _PROTOTYPE( int pty_write, (tty_t *tp, int try) ); FORWARD _PROTOTYPE( void pty_echo, (tty_t *tp, int c) ); FORWARD _PROTOTYPE( void pty_start, (pty_t *pp) ); FORWARD _PROTOTYPE( void pty_finish, (pty_t *pp) ); @@ -75,9 +75,9 @@ FORWARD _PROTOTYPE( int pty_icancel, (tty_t *tp, int try) ); FORWARD _PROTOTYPE( int pty_ocancel, (tty_t *tp, int try) ); FORWARD _PROTOTYPE( int pty_select, (tty_t *tp, message *m) ); -/*==========================================================================* - * do_pty * - *==========================================================================*/ +/*===========================================================================* + * do_pty * + *===========================================================================*/ PUBLIC void do_pty(tp, m_ptr) tty_t *tp; message *m_ptr; @@ -209,9 +209,9 @@ message *m_ptr; tty_reply(TASK_REPLY, m_ptr->m_source, m_ptr->PROC_NR, r); } -/*==========================================================================* - * pty_write * - *==========================================================================*/ +/*===========================================================================* + * pty_write * + *===========================================================================*/ PRIVATE int pty_write(tp, try) tty_t *tp; int try; @@ -225,7 +225,7 @@ int try; /* PTY closed down? */ if (pp->state & PTY_CLOSED) { - if(try) return 1; + if (try) return 1; if (tp->tty_outleft > 0) { tty_reply(tp->tty_outrepcode, tp->tty_outcaller, tp->tty_outproc, EIO); @@ -237,7 +237,7 @@ int try; /* While there is something to do. */ for (;;) { ocount = buflen(pp->obuf) - pp->ocount; - if(try) return (ocount > 0); + if (try) return (ocount > 0); count = bufend(pp->obuf) - pp->ohead; if (count > ocount) count = ocount; if (count > tp->tty_outleft) count = tp->tty_outleft; @@ -245,7 +245,7 @@ int try; break; /* Copy from user space to the PTY output buffer. */ - if((s = sys_vircopy(tp->tty_outproc, D, (vir_bytes) tp->tty_out_vir, + if ((s = sys_vircopy(tp->tty_outproc, D, (vir_bytes) tp->tty_out_vir, SELF, D, (vir_bytes) pp->ohead, (phys_bytes) count)) != OK) { printf("pty tty%d: copy failed (error %d)\n", s); break; @@ -276,9 +276,9 @@ int try; return 1; } -/*==========================================================================* - * pty_echo * - *==========================================================================*/ +/*===========================================================================* + * pty_echo * + *===========================================================================*/ PRIVATE void pty_echo(tp, c) tty_t *tp; int c; @@ -301,9 +301,9 @@ int c; pty_start(pp); } -/*==========================================================================* - * pty_start * - *==========================================================================*/ +/*===========================================================================* + * pty_start * + *===========================================================================*/ PRIVATE void pty_start(pp) pty_t *pp; { @@ -319,7 +319,7 @@ pty_t *pp; if (count == 0) break; /* Copy from the output buffer to the readers address space. */ - if((s = sys_vircopy(SELF, D, (vir_bytes)pp->otail, + if ((s = sys_vircopy(SELF, D, (vir_bytes)pp->otail, (vir_bytes) pp->rdproc, D, (vir_bytes) pp->rdvir, (phys_bytes) count)) != OK) { printf("pty tty%d: copy failed (error %d)\n", s); break; @@ -334,9 +334,9 @@ pty_t *pp; } } -/*==========================================================================* - * pty_finish * - *==========================================================================*/ +/*===========================================================================* + * pty_finish * + *===========================================================================*/ PRIVATE void pty_finish(pp) pty_t *pp; { @@ -354,9 +354,9 @@ pty_t *pp; } -/*==========================================================================* - * pty_read * - *==========================================================================*/ +/*===========================================================================* + * pty_read * + *===========================================================================*/ PRIVATE int pty_read(tp, try) tty_t *tp; int try; @@ -368,7 +368,7 @@ int try; char c; if (pp->state & PTY_CLOSED) { - if(try) return 1; + if (try) return 1; if (tp->tty_inleft > 0) { tty_reply(tp->tty_inrepcode, tp->tty_incaller, tp->tty_inproc, tp->tty_incum); @@ -377,8 +377,8 @@ int try; return 1; } - if(try) { - if(pp->wrleft > 0) + if (try) { + if (pp->wrleft > 0) return 1; return 0; } @@ -387,7 +387,7 @@ int try; int s; /* Transfer one character to 'c'. */ - if((s = sys_vircopy(pp->wrproc, D, (vir_bytes) pp->wrvir, + if ((s = sys_vircopy(pp->wrproc, D, (vir_bytes) pp->wrvir, SELF, D, (vir_bytes) &c, (phys_bytes) 1)) != OK) { printf("pty: copy failed (error %d)\n", s); break; @@ -411,9 +411,9 @@ int try; } } -/*==========================================================================* - * pty_close * - *==========================================================================*/ +/*===========================================================================* + * pty_close * + *===========================================================================*/ PRIVATE int pty_close(tp, try) tty_t *tp; int try; @@ -436,9 +436,9 @@ int try; if (pp->state & PTY_CLOSED) pp->state = 0; else pp->state |= TTY_CLOSED; } -/*==========================================================================* - * pty_icancel * - *==========================================================================*/ +/*===========================================================================* + * pty_icancel * + *===========================================================================*/ PRIVATE int pty_icancel(tp, try) tty_t *tp; int try; @@ -454,9 +454,9 @@ int try; } } -/*==========================================================================* - * pty_ocancel * - *==========================================================================*/ +/*===========================================================================* + * pty_ocancel * + *===========================================================================*/ PRIVATE int pty_ocancel(tp, try) tty_t *tp; int try; @@ -468,9 +468,9 @@ int try; pp->otail = pp->ohead; } -/*==========================================================================* - * pty_init * - *==========================================================================*/ +/*===========================================================================* + * pty_init * + *===========================================================================*/ PUBLIC void pty_init(tp) tty_t *tp; { @@ -496,9 +496,9 @@ tty_t *tp; tp->tty_select_ops = 0; } -/*==========================================================================* - * pty_status * - *==========================================================================*/ +/*===========================================================================* + * pty_status * + *===========================================================================*/ PUBLIC int pty_status(message *m_ptr) { int i, event_found; @@ -535,7 +535,7 @@ PUBLIC int pty_status(message *m_ptr) break; } - if(pp->select_ready_ops && pp->select_proc == m_ptr->m_source) { + if (pp->select_ready_ops && pp->select_proc == m_ptr->m_source) { m_ptr->m_type = DEV_IO_READY; m_ptr->DEV_MINOR = PTYPX_MINOR + i; m_ptr->DEV_SEL_OPS = pp->select_ready_ops; @@ -547,50 +547,50 @@ PUBLIC int pty_status(message *m_ptr) return event_found; } -/*==========================================================================* - * select_try_pty * - *==========================================================================*/ +/*===========================================================================* + * select_try_pty * + *===========================================================================*/ PRIVATE int select_try_pty(tty_t *tp, int ops) { pty_t *pp = tp->tty_priv; int r = 0; - if(ops & SEL_WR) { + if (ops & SEL_WR) { /* Write won't block on error. */ if (pp->state & TTY_CLOSED) r |= SEL_WR; else if (pp->wrleft != 0 || pp->wrcum != 0) r |= SEL_WR; else r |= SEL_WR; } - if(ops & SEL_RD) { + if (ops & SEL_RD) { /* Read won't block on error. */ if (pp->state & TTY_CLOSED) r |= SEL_RD; - else if(pp->rdleft != 0 || pp->rdcum != 0) r |= SEL_RD; - else if(pp->ocount > 0) r |= SEL_RD; /* Actual data. */ + else if (pp->rdleft != 0 || pp->rdcum != 0) r |= SEL_RD; + else if (pp->ocount > 0) r |= SEL_RD; /* Actual data. */ } return r; } -/*==========================================================================* - * select_retry_pty * - *==========================================================================*/ +/*===========================================================================* + * select_retry_pty * + *===========================================================================*/ PUBLIC void select_retry_pty(tty_t *tp) { pty_t *pp = tp->tty_priv; int r; /* See if the pty side of a pty is ready to return a select. */ - if(pp->select_ops && (r=select_try_pty(tp, pp->select_ops))) { + if (pp->select_ops && (r=select_try_pty(tp, pp->select_ops))) { pp->select_ops &= ~r; pp->select_ready_ops |= r; notify(pp->select_proc); } } -/*==========================================================================* - * pty_select * - *==========================================================================*/ +/*===========================================================================* + * pty_select * + *===========================================================================*/ PRIVATE int pty_select(tty_t *tp, message *m) { pty_t *pp = tp->tty_priv; @@ -601,7 +601,7 @@ PRIVATE int pty_select(tty_t *tp, message *m) ready_ops = select_try_pty(tp, ops); - if(!ready_ops && ops && watch) { + if (!ready_ops && ops && watch) { pp->select_ops |= ops; pp->select_proc = m->m_source; } diff --git a/drivers/tty/rs232.c b/drivers/tty/rs232.c index da58e8c69..3e28c5b36 100644 --- a/drivers/tty/rs232.c +++ b/drivers/tty/rs232.c @@ -1,8 +1,8 @@ #include -/*==========================================================================* - * rs232.c - serial driver for 8250 and 16450 UARTs * - * Added support for Atari ST M68901 and YM-2149 --kub * - *==========================================================================*/ +/*---------------------------------------------------------------------------* + * rs232.c - serial driver for 8250 and 16450 UARTs * + * Added support for Atari ST M68901 and YM-2149 --kub * + *---------------------------------------------------------------------------*/ #include "../drivers.h" #include @@ -252,16 +252,16 @@ PRIVATE port_t addr_8250[] = { FORWARD _PROTOTYPE( void in_int, (rs232_t *rs) ); FORWARD _PROTOTYPE( void line_int, (rs232_t *rs) ); FORWARD _PROTOTYPE( void modem_int, (rs232_t *rs) ); -FORWARD _PROTOTYPE( int rs_write, (tty_t *tp, int try) ); +FORWARD _PROTOTYPE( int rs_write, (tty_t *tp, int try) ); FORWARD _PROTOTYPE( void rs_echo, (tty_t *tp, int c) ); -FORWARD _PROTOTYPE( int rs_ioctl, (tty_t *tp, int try) ); +FORWARD _PROTOTYPE( int rs_ioctl, (tty_t *tp, int try) ); FORWARD _PROTOTYPE( void rs_config, (rs232_t *rs) ); -FORWARD _PROTOTYPE( int rs_read, (tty_t *tp, int try) ); -FORWARD _PROTOTYPE( int rs_icancel, (tty_t *tp, int try) ); -FORWARD _PROTOTYPE( int rs_ocancel, (tty_t *tp, int try) ); +FORWARD _PROTOTYPE( int rs_read, (tty_t *tp, int try) ); +FORWARD _PROTOTYPE( int rs_icancel, (tty_t *tp, int try) ); +FORWARD _PROTOTYPE( int rs_ocancel, (tty_t *tp, int try) ); FORWARD _PROTOTYPE( void rs_ostart, (rs232_t *rs) ); -FORWARD _PROTOTYPE( int rs_break, (tty_t *tp, int try) ); -FORWARD _PROTOTYPE( int rs_close, (tty_t *tp, int try) ); +FORWARD _PROTOTYPE( int rs_break, (tty_t *tp, int try) ); +FORWARD _PROTOTYPE( int rs_close, (tty_t *tp, int try) ); FORWARD _PROTOTYPE( void out_int, (rs232_t *rs) ); FORWARD _PROTOTYPE( void rs232_handler, (rs232_t *rs) ); @@ -273,15 +273,15 @@ PRIVATE int my_inb(port_t port) { int r, v = 0; r = sys_inb(port, &v); - if(r != OK) + if (r != OK) printf("RS232 warning: failed inb 0x%x\n", port); return v; } -/*==========================================================================* - * rs_write * - *==========================================================================*/ +/*===========================================================================* + * rs_write * + *===========================================================================*/ PRIVATE int rs_write(tp, try) register tty_t *tp; int try; @@ -314,10 +314,10 @@ int try; if (count > ocount) count = ocount; if (count > tp->tty_outleft) count = tp->tty_outleft; if (count == 0 || tp->tty_inhibited) { - if(try) return 0; + if (try) return 0; break; } - if(try) return 1; + if (try) return 1; /* Copy from user space to the RS232 output buffer. */ sys_vircopy(tp->tty_outproc, D, (vir_bytes) tp->tty_out_vir, @@ -355,9 +355,9 @@ int try; return 1; } -/*==========================================================================* - * rs_echo * - *==========================================================================*/ +/*===========================================================================* + * rs_echo * + *===========================================================================*/ PRIVATE void rs_echo(tp, c) tty_t *tp; /* which TTY */ int c; /* character to echo */ @@ -382,9 +382,9 @@ int c; /* character to echo */ if ((rs->ohead += ocount) >= bufend(rs->obuf)) rs->ohead -= buflen(rs->obuf); } -/*==========================================================================* - * rs_ioctl * - *==========================================================================*/ +/*===========================================================================* + * rs_ioctl * + *===========================================================================*/ PRIVATE int rs_ioctl(tp, dummy) tty_t *tp; /* which TTY */ int dummy; @@ -396,9 +396,9 @@ int dummy; return 0; /* dummy */ } -/*==========================================================================* - * rs_config * - *==========================================================================*/ +/*===========================================================================* + * rs_config * + *===========================================================================*/ PRIVATE void rs_config(rs) rs232_t *rs; /* which line */ { @@ -504,9 +504,9 @@ rs232_t *rs; /* which line */ #endif /* MACHINE == ATARI */ } -/*==========================================================================* - * rs_init * - *==========================================================================*/ +/*===========================================================================* + * rs_init * + *===========================================================================*/ PUBLIC void rs_init(tp) tty_t *tp; /* which TTY */ { @@ -580,10 +580,10 @@ tty_t *tp; /* which TTY */ rs->irq = irq; rs->irq_hook_id = rs->irq; /* call back with irq line number */ - if(sys_irqsetpolicy(irq, IRQ_REENABLE, &rs->irq_hook_id) != OK) { + if (sys_irqsetpolicy(irq, IRQ_REENABLE, &rs->irq_hook_id) != OK) { printf("RS232: Couldn't obtain hook for irq %d\n", irq); } else { - if(sys_irqenable(&rs->irq_hook_id) != OK) { + if (sys_irqenable(&rs->irq_hook_id) != OK) { printf("RS232: Couldn't enable irq %d (hooked)\n", irq); } } @@ -622,9 +622,9 @@ tty_t *tp; /* which TTY */ } -/*==========================================================================* - * rs_interrupt * - *==========================================================================*/ +/*===========================================================================* + * rs_interrupt * + *===========================================================================*/ PUBLIC void rs_interrupt(m) message *m; /* which TTY */ { @@ -640,9 +640,9 @@ message *m; /* which TTY */ } } -/*==========================================================================* - * rs_icancel * - *==========================================================================*/ +/*===========================================================================* + * rs_icancel * + *===========================================================================*/ PRIVATE int rs_icancel(tp, dummy) tty_t *tp; /* which TTY */ int dummy; @@ -659,9 +659,9 @@ int dummy; return 0; /* dummy */ } -/*==========================================================================* - * rs_ocancel * - *==========================================================================*/ +/*===========================================================================* + * rs_ocancel * + *===========================================================================*/ PRIVATE int rs_ocancel(tp, dummy) tty_t *tp; /* which TTY */ int dummy; @@ -678,9 +678,9 @@ int dummy; return 0; /* dummy */ } -/*==========================================================================* - * rs_read * - *==========================================================================*/ +/*===========================================================================* + * rs_read * + *===========================================================================*/ PRIVATE int rs_read(tp, try) tty_t *tp; /* which tty */ int try; @@ -691,7 +691,7 @@ int try; int icount, count, ostate; if (!(tp->tty_termios.c_cflag & CLOCAL)) { - if(try) return 1; + if (try) return 1; /* Send a SIGHUP if hangup detected. */ lock(); ostate = rs->ostate; @@ -704,8 +704,8 @@ int try; } } - if(try) { - if(rs->icount > 0) + if (try) { + if (rs->icount > 0) return 1; return 0; } @@ -725,9 +725,9 @@ int try; } } -/*==========================================================================* - * rs_ostart * - *==========================================================================*/ +/*===========================================================================* + * rs_ostart * + *===========================================================================*/ PRIVATE void rs_ostart(rs) rs232_t *rs; /* which rs line */ { @@ -737,9 +737,9 @@ rs232_t *rs; /* which rs line */ if (txready(rs)) out_int(rs); } -/*==========================================================================* - * rs_break * - *==========================================================================*/ +/*===========================================================================* + * rs_break * + *===========================================================================*/ PRIVATE int rs_break(tp, dummy) tty_t *tp; /* which tty */ int dummy; @@ -757,9 +757,9 @@ int dummy; return 0; /* dummy */ } -/*==========================================================================* - * rs_close * - *==========================================================================*/ +/*===========================================================================* + * rs_close * + *===========================================================================*/ PRIVATE int rs_close(tp, dummy) tty_t *tp; /* which tty */ int dummy; @@ -777,9 +777,9 @@ int dummy; /* Low level (interrupt) routines. */ #if (MACHINE == IBM_PC) -/*==========================================================================* - * rs232_handler * - *==========================================================================*/ +/*===========================================================================* + * rs232_handler * + *===========================================================================*/ PRIVATE void rs232_handler(rs) struct rs232 *rs; { @@ -813,9 +813,9 @@ struct rs232 *rs; #endif /* MACHINE == IBM_PC */ #if (MACHINE == ATARI) -/*==========================================================================* - * siaint * - *==========================================================================*/ +/*===========================================================================* + * siaint * + *===========================================================================*/ PRIVATE void siaint(type) int type; /* interrupt type */ { @@ -855,9 +855,9 @@ int type; /* interrupt type */ } #endif /* MACHINE == ATARI */ -/*==========================================================================* - * in_int * - *==========================================================================*/ +/*===========================================================================* + * in_int * + *===========================================================================*/ PRIVATE void in_int(rs) register rs232_t *rs; /* line with input interrupt */ { @@ -897,9 +897,9 @@ register rs232_t *rs; /* line with input interrupt */ } } -/*==========================================================================* - * line_int * - *==========================================================================*/ +/*===========================================================================* + * line_int * + *===========================================================================*/ PRIVATE void line_int(rs) register rs232_t *rs; /* line with line status interrupt */ { @@ -918,9 +918,9 @@ register rs232_t *rs; /* line with line status interrupt */ if (rs->lstatus & LS_BREAK_INTERRUPT) ++rs->break_interrupts; } -/*==========================================================================* - * modem_int * - *==========================================================================*/ +/*===========================================================================* + * modem_int * + *===========================================================================*/ PRIVATE void modem_int(rs) register rs232_t *rs; /* line with modem interrupt */ { @@ -948,9 +948,9 @@ register rs232_t *rs; /* line with modem interrupt */ } } -/*==========================================================================* +/*===========================================================================* * out_int * - *==========================================================================*/ + *===========================================================================*/ PRIVATE void out_int(rs) register rs232_t *rs; /* line with output interrupt */ { diff --git a/drivers/tty/tty.c b/drivers/tty/tty.c index 9961f393f..8dc4904fa 100644 --- a/drivers/tty/tty.c +++ b/drivers/tty/tty.c @@ -33,7 +33,7 @@ * --------------------------------------------------------------------------- * | HARD_INT | | | | | | | * |-------------+---------+---------+---------+---------+---------+---------| - * | SYS_SIG | sig set | | | | | | + * | SYS_SIG | sig set | | | | | | * |-------------+---------+---------+---------+---------+---------+---------| * | DEV_READ |minor dev| proc nr | count | O_NONBLOCK| buf ptr | * |-------------+---------+---------+---------+---------+---------+---------| @@ -419,7 +419,7 @@ register message *m_ptr; /* pointer to message sent to the task */ /* ...then go back for more. */ handle_events(tp); if (tp->tty_inleft == 0) { - if(tp->tty_select_ops) + if (tp->tty_select_ops) select_retry(tp); return; /* already done */ } @@ -436,7 +436,7 @@ register message *m_ptr; /* pointer to message sent to the task */ } } tty_reply(TASK_REPLY, m_ptr->m_source, m_ptr->PROC_NR, r); - if(tp->tty_select_ops) + if (tp->tty_select_ops) select_retry(tp); } @@ -595,9 +595,9 @@ message *m_ptr; /* pointer to message sent to task */ SELF, D, (vir_bytes) ¶m.i, (vir_bytes) size); if (r != OK) break; switch (param.i) { - case TCIFLUSH: tty_icancel(tp); break; - case TCOFLUSH: (*tp->tty_ocancel)(tp, 0); break; - case TCIOFLUSH: tty_icancel(tp); (*tp->tty_ocancel)(tp, 0);break; + case TCIFLUSH: tty_icancel(tp); break; + case TCOFLUSH: (*tp->tty_ocancel)(tp, 0); break; + case TCIOFLUSH: tty_icancel(tp); (*tp->tty_ocancel)(tp, 0); break; default: r = EINVAL; } break; @@ -798,25 +798,25 @@ PUBLIC int select_try(struct tty *tp, int ops) ready_ops |= ops; } - if(ops & SEL_RD) { + if (ops & SEL_RD) { /* will i/o not block on read? */ if (tp->tty_inleft > 0) { ready_ops |= SEL_RD; /* EIO - no blocking */ - } else if(tp->tty_incount > 0) { + } else if (tp->tty_incount > 0) { /* Is a regular read possible? tty_incount * says there is data. But a read will only succeed * in canonical mode if a newline has been seen. */ - if(!(tp->tty_termios.c_lflag & ICANON) || + if (!(tp->tty_termios.c_lflag & ICANON) || tp->tty_eotct > 0) { ready_ops |= SEL_RD; } } } - if(ops & SEL_WR) { + if (ops & SEL_WR) { if (tp->tty_outleft > 0) ready_ops |= SEL_WR; - else if((*tp->tty_devwrite)(tp, 1)) ready_ops |= SEL_WR; + else if ((*tp->tty_devwrite)(tp, 1)) ready_ops |= SEL_WR; } return ready_ops; @@ -879,10 +879,10 @@ tty_t *tp; /* TTY to check for events. */ tp->tty_inleft = tp->tty_incum = 0; } } - if(tp->tty_select_ops) + if (tp->tty_select_ops) select_retry(tp); #if NR_PTYS > 0 - if(ispty(tp)) + if (ispty(tp)) select_retry_pty(tp); #endif } @@ -1179,9 +1179,9 @@ register int ch; /* pointer to character to echo */ return(ch | (len << IN_LSHIFT)); } -/*==========================================================================* - * rawecho * - *==========================================================================*/ +/*===========================================================================* + * rawecho * + *===========================================================================*/ PRIVATE void rawecho(tp, ch) register tty_t *tp; int ch; @@ -1192,9 +1192,9 @@ int ch; tp->tty_reprint = rp; } -/*==========================================================================* - * back_over * - *==========================================================================*/ +/*===========================================================================* + * back_over * + *===========================================================================*/ PRIVATE int back_over(tp) register tty_t *tp; { @@ -1221,9 +1221,9 @@ register tty_t *tp; return(1); /* one character erased */ } -/*==========================================================================* - * reprint * - *==========================================================================*/ +/*===========================================================================* + * reprint * + *===========================================================================*/ PRIVATE void reprint(tp) register tty_t *tp; /* pointer to tty struct */ { @@ -1260,9 +1260,9 @@ register tty_t *tp; /* pointer to tty struct */ } while (count < tp->tty_incount); } -/*==========================================================================* - * out_process * - *==========================================================================*/ +/*===========================================================================* + * out_process * + *===========================================================================*/ PUBLIC void out_process(tp, bstart, bpos, bend, icount, ocount) tty_t *tp; char *bstart, *bpos, *bend; /* start/pos/end of circular buffer */ @@ -1471,9 +1471,9 @@ int sig; /* SIGINT, SIGQUIT, SIGKILL or SIGHUP */ } } -/*==========================================================================* - * tty_icancel * - *==========================================================================*/ +/*===========================================================================* + * tty_icancel * + *===========================================================================*/ PRIVATE void tty_icancel(tp) register tty_t *tp; { @@ -1484,9 +1484,9 @@ register tty_t *tp; (*tp->tty_icancel)(tp, 0); } -/*==========================================================================* - * tty_init * - *==========================================================================*/ +/*===========================================================================* + * tty_init * + *===========================================================================*/ PRIVATE void tty_init() { /* Initialize tty structure and call device initialization routines. */ @@ -1530,9 +1530,9 @@ PRIVATE void tty_init() #endif } -/*==========================================================================* - * tty_timed_out * - *==========================================================================*/ +/*===========================================================================* + * tty_timed_out * + *===========================================================================*/ PRIVATE void tty_timed_out(timer_t *tp) { /* This timer has expired. Set the events flag, to force processing. */ @@ -1542,9 +1542,9 @@ PRIVATE void tty_timed_out(timer_t *tp) tty_ptr->tty_events = 1; } -/*==========================================================================* - * expire_timers * - *==========================================================================*/ +/*===========================================================================* + * expire_timers * + *===========================================================================*/ PRIVATE void expire_timers(void) { /* A synchronous alarm message was received. Check if there are any expired @@ -1605,9 +1605,9 @@ int enable; /* set timer if true, otherwise unset */ } } -/*==========================================================================* - * tty_devnop * - *==========================================================================*/ +/*===========================================================================* + * tty_devnop * + *===========================================================================*/ PUBLIC int tty_devnop(tp, try) tty_t *tp; int try; @@ -1616,7 +1616,7 @@ int try; } /*===========================================================================* - * do_select * + * do_select * *===========================================================================*/ PRIVATE void do_select(tp, m_ptr) register tty_t *tp; /* pointer to tty struct */ @@ -1629,7 +1629,7 @@ register message *m_ptr; /* pointer to message sent to the task */ ready_ops = select_try(tp, ops); - if(!ready_ops && ops && watch) { + if (!ready_ops && ops && watch) { tp->tty_select_ops |= ops; tp->tty_select_proc = m_ptr->m_source; } diff --git a/drivers/tty/tty.h b/drivers/tty/tty.h index 010a200d1..f26ca22b2 100644 --- a/drivers/tty/tty.h +++ b/drivers/tty/tty.h @@ -3,11 +3,11 @@ #include /* First minor numbers for the various classes of TTY devices. */ -#define CONS_MINOR 0 -#define LOG_MINOR 15 -#define RS232_MINOR 16 -#define TTYPX_MINOR 128 -#define PTYPX_MINOR 192 +#define CONS_MINOR 0 +#define LOG_MINOR 15 +#define RS232_MINOR 16 +#define TTYPX_MINOR 128 +#define PTYPX_MINOR 192 #define LINEWRAP 1 /* console.c - wrap lines at column 80 */ @@ -135,8 +135,8 @@ _PROTOTYPE( void out_process, (struct tty *tp, char *bstart, char *bpos, _PROTOTYPE( void tty_wakeup, (clock_t now) ); _PROTOTYPE( void tty_reply, (int code, int replyee, int proc_nr, int status) ); -_PROTOTYPE( int tty_devnop, (struct tty *tp, int try) ); -_PROTOTYPE( int select_try, (struct tty *tp, int ops) ); +_PROTOTYPE( int tty_devnop, (struct tty *tp, int try) ); +_PROTOTYPE( int select_try, (struct tty *tp, int ops) ); _PROTOTYPE( int select_retry, (struct tty *tp) ); /* rs232.c */ @@ -147,7 +147,7 @@ _PROTOTYPE( void rs_interrupt, (message *m) ); /* console.c */ _PROTOTYPE( void kputc, (int c) ); _PROTOTYPE( void cons_stop, (void) ); -_PROTOTYPE( void do_new_kmess, (message *m) ); +_PROTOTYPE( void do_new_kmess, (message *m) ); _PROTOTYPE( void do_diagnostics, (message *m) ); _PROTOTYPE( void scr_init, (struct tty *tp) ); _PROTOTYPE( void toggle_scroll, (void) ); @@ -165,7 +165,7 @@ _PROTOTYPE( void kbd_interrupt, (message *m) ); /* pty.c */ _PROTOTYPE( void do_pty, (struct tty *tp, message *m_ptr) ); _PROTOTYPE( void pty_init, (struct tty *tp) ); -_PROTOTYPE( void select_retry_pty, (struct tty *tp) ); +_PROTOTYPE( void select_retry_pty, (struct tty *tp) ); _PROTOTYPE( int pty_status, (message *m_ptr) ); /* vidcopy.s */