#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 */
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. */
return(OK);
}
-/*============================================================================*
- * init_params *
- *============================================================================*/
+/*===========================================================================*
+ * init_params *
+ *===========================================================================*/
PRIVATE void init_params()
{
/* This routine is called at startup to initialize the drive parameters. */
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)
/* 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);
#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;
w->lba48 = 0;
}
-/*============================================================================*
- * init_params_pci *
- *============================================================================*/
+/*===========================================================================*
+ * init_params_pci *
+ *===========================================================================*/
PRIVATE void init_params_pci(int skip)
{
int r, devind, drive;
/* 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;
}
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;
}
/* 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);
}
}
}
-/*============================================================================*
- * w_do_open *
- *============================================================================*/
+/*===========================================================================*
+ * w_do_open *
+ *===========================================================================*/
PRIVATE int w_do_open(dp, m_ptr)
struct driver *dp;
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);
}
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
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 */
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;
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. */
w_testing = 0;
/* Test if everything worked. */
- if(r != OK || iov.iov_size != 0) {
+ if (r != OK || iov.iov_size != 0) {
return ERR;
}
return(OK);
}
-/*============================================================================*
- * com_out *
- *============================================================================*/
+/*===========================================================================*
+ * com_out *
+ *===========================================================================*/
PRIVATE int com_out(cmd)
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());
}
}
-/*============================================================================*
- * w_do_close *
- *============================================================================*/
+/*===========================================================================*
+ * w_do_close *
+ *===========================================================================*/
PRIVATE int w_do_close(dp, m_ptr)
struct driver *dp;
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;
/*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;
}
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);
return(OK);
}
-/*============================================================================*
- * w_intr_wait *
- *============================================================================*/
+/*===========================================================================*
+ * w_intr_wait *
+ *===========================================================================*/
PRIVATE void w_intr_wait()
{
/* Wait for a task completion interrupt. */
}
}
-/*============================================================================*
- * at_intr_wait *
- *============================================================================*/
+/*===========================================================================*
+ * at_intr_wait *
+ *===========================================================================*/
PRIVATE int at_intr_wait()
{
/* Wait for an interrupt, study the status bits and return error/success. */
return(r);
}
-/*==========================================================================*
- * w_waitfor *
- *==========================================================================*/
+/*===========================================================================*
+ * w_waitfor *
+ *===========================================================================*/
PRIVATE int w_waitfor(mask, value)
int mask; /* status mask */
int value; /* required status */
return(0);
}
-/*============================================================================*
- * w_geometry *
- *============================================================================*/
+/*===========================================================================*
+ * w_geometry *
+ *===========================================================================*/
PRIVATE void w_geometry(entry)
struct partition *entry;
{
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");
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);
}
}
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)
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);
{
int p;
- if(atapi_debug) {
+ if (atapi_debug) {
printf("sent command:");
for(p = 0; p < ATAPI_PACKETSIZE; p++) { printf(" %02x", packet[p]); }
printf("\n");
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.
*/
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;
}
-/*============================================================================*
- * w_hw_int *
- *============================================================================*/
+/*===========================================================================*
+ * w_hw_int *
+ *===========================================================================*/
PRIVATE int w_hw_int(dr, m)
struct driver *dr;
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);
}
-#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];
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
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;
_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 */
* 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)
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 = {
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);
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);
return(OK);
}
-/*==========================================================================*
- * fdc_results *
- *==========================================================================*/
+/*===========================================================================*
+ * fdc_results *
+ *===========================================================================*/
PRIVATE int fdc_results()
{
/* Extract results from the controller after an operation, then allow floppy
}
}
-/*==========================================================================*
- * read_id *
- *==========================================================================*/
+/*===========================================================================*
+ * read_id *
+ *===========================================================================*/
PRIVATE int read_id()
{
/* Determine current cylinder and sector. */
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 */
return(EIO); /* nothing worked */
}
-/*==========================================================================*
- * test_read *
- *==========================================================================*/
+/*===========================================================================*
+ * test_read *
+ *===========================================================================*/
PRIVATE int test_read(density)
int density;
{
return(OK);
}
-/*============================================================================*
- * f_geometry *
- *============================================================================*/
+/*===========================================================================*
+ * f_geometry *
+ *===========================================================================*/
PRIVATE void f_geometry(entry)
struct partition *entry;
{
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 = {
return(OK);
}
-/*============================================================================*
- * m_do_open *
- *============================================================================*/
+/*===========================================================================*
+ * m_do_open *
+ *===========================================================================*/
PRIVATE int m_do_open(dp, m_ptr)
struct driver *dp;
message *m_ptr;
return(OK);
}
-/*============================================================================*
- * m_geometry *
- *============================================================================*/
+/*===========================================================================*
+ * m_geometry *
+ *===========================================================================*/
PRIVATE void m_geometry(entry)
struct partition *entry;
{
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) );
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) );
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.
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);
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;
{
prev_next = kmess.km_next;
}
-/*==========================================================================*
- * do_diagnostics *
- *==========================================================================*/
+/*===========================================================================*
+ * do_diagnostics *
+ *===========================================================================*/
PUBLIC void do_diagnostics(m_ptr)
message *m_ptr; /* pointer to request message */
{
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 *
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;
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;
}
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. */
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. */
}
/*===========================================================================*
- * kb_init_once *
+ * kb_init_once *
*===========================================================================*/
PUBLIC void kb_init_once(void)
{
return(TRUE);
}
-/*==========================================================================*
- * show_key_mappings *
- *==========================================================================*/
+/*===========================================================================*
+ * show_key_mappings *
+ *===========================================================================*/
PRIVATE void show_key_mappings()
{
int i,s;
printf("\n");
}
-/*==========================================================================*
- * scan_keyboard *
- *==========================================================================*/
+/*===========================================================================*
+ * scan_keyboard *
+ *===========================================================================*/
PRIVATE int scan_keyboard()
{
/* Fetch the character from the keyboard hardware and acknowledge it. */
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 */
{
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) );
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;
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;
/* 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);
/* 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;
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;
return 1;
}
-/*==========================================================================*
- * pty_echo *
- *==========================================================================*/
+/*===========================================================================*
+ * pty_echo *
+ *===========================================================================*/
PRIVATE void pty_echo(tp, c)
tty_t *tp;
int c;
pty_start(pp);
}
-/*==========================================================================*
- * pty_start *
- *==========================================================================*/
+/*===========================================================================*
+ * pty_start *
+ *===========================================================================*/
PRIVATE void pty_start(pp)
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;
}
}
-/*==========================================================================*
- * pty_finish *
- *==========================================================================*/
+/*===========================================================================*
+ * pty_finish *
+ *===========================================================================*/
PRIVATE void pty_finish(pp)
pty_t *pp;
{
}
-/*==========================================================================*
- * pty_read *
- *==========================================================================*/
+/*===========================================================================*
+ * pty_read *
+ *===========================================================================*/
PRIVATE int pty_read(tp, try)
tty_t *tp;
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);
return 1;
}
- if(try) {
- if(pp->wrleft > 0)
+ if (try) {
+ if (pp->wrleft > 0)
return 1;
return 0;
}
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;
}
}
-/*==========================================================================*
- * pty_close *
- *==========================================================================*/
+/*===========================================================================*
+ * pty_close *
+ *===========================================================================*/
PRIVATE int pty_close(tp, try)
tty_t *tp;
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;
}
}
-/*==========================================================================*
- * pty_ocancel *
- *==========================================================================*/
+/*===========================================================================*
+ * pty_ocancel *
+ *===========================================================================*/
PRIVATE int pty_ocancel(tp, try)
tty_t *tp;
int try;
pp->otail = pp->ohead;
}
-/*==========================================================================*
- * pty_init *
- *==========================================================================*/
+/*===========================================================================*
+ * pty_init *
+ *===========================================================================*/
PUBLIC void pty_init(tp)
tty_t *tp;
{
tp->tty_select_ops = 0;
}
-/*==========================================================================*
- * pty_status *
- *==========================================================================*/
+/*===========================================================================*
+ * pty_status *
+ *===========================================================================*/
PUBLIC int pty_status(message *m_ptr)
{
int i, event_found;
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;
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;
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;
}
#include <minix/config.h>
-/*==========================================================================*
- * 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 <termios.h>
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) );
{
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;
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,
return 1;
}
-/*==========================================================================*
- * rs_echo *
- *==========================================================================*/
+/*===========================================================================*
+ * rs_echo *
+ *===========================================================================*/
PRIVATE void rs_echo(tp, c)
tty_t *tp; /* which TTY */
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;
return 0; /* dummy */
}
-/*==========================================================================*
- * rs_config *
- *==========================================================================*/
+/*===========================================================================*
+ * rs_config *
+ *===========================================================================*/
PRIVATE void rs_config(rs)
rs232_t *rs; /* which line */
{
#endif /* MACHINE == ATARI */
}
-/*==========================================================================*
- * rs_init *
- *==========================================================================*/
+/*===========================================================================*
+ * rs_init *
+ *===========================================================================*/
PUBLIC void rs_init(tp)
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);
}
}
}
-/*==========================================================================*
- * rs_interrupt *
- *==========================================================================*/
+/*===========================================================================*
+ * rs_interrupt *
+ *===========================================================================*/
PUBLIC void rs_interrupt(m)
message *m; /* which TTY */
{
}
}
-/*==========================================================================*
- * rs_icancel *
- *==========================================================================*/
+/*===========================================================================*
+ * rs_icancel *
+ *===========================================================================*/
PRIVATE int rs_icancel(tp, dummy)
tty_t *tp; /* which TTY */
int dummy;
return 0; /* dummy */
}
-/*==========================================================================*
- * rs_ocancel *
- *==========================================================================*/
+/*===========================================================================*
+ * rs_ocancel *
+ *===========================================================================*/
PRIVATE int rs_ocancel(tp, dummy)
tty_t *tp; /* which TTY */
int dummy;
return 0; /* dummy */
}
-/*==========================================================================*
- * rs_read *
- *==========================================================================*/
+/*===========================================================================*
+ * rs_read *
+ *===========================================================================*/
PRIVATE int rs_read(tp, try)
tty_t *tp; /* which tty */
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;
}
}
- if(try) {
- if(rs->icount > 0)
+ if (try) {
+ if (rs->icount > 0)
return 1;
return 0;
}
}
}
-/*==========================================================================*
- * rs_ostart *
- *==========================================================================*/
+/*===========================================================================*
+ * rs_ostart *
+ *===========================================================================*/
PRIVATE void rs_ostart(rs)
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;
return 0; /* dummy */
}
-/*==========================================================================*
- * rs_close *
- *==========================================================================*/
+/*===========================================================================*
+ * rs_close *
+ *===========================================================================*/
PRIVATE int rs_close(tp, dummy)
tty_t *tp; /* which tty */
int dummy;
/* Low level (interrupt) routines. */
#if (MACHINE == IBM_PC)
-/*==========================================================================*
- * rs232_handler *
- *==========================================================================*/
+/*===========================================================================*
+ * rs232_handler *
+ *===========================================================================*/
PRIVATE void rs232_handler(rs)
struct rs232 *rs;
{
#endif /* MACHINE == IBM_PC */
#if (MACHINE == ATARI)
-/*==========================================================================*
- * siaint *
- *==========================================================================*/
+/*===========================================================================*
+ * siaint *
+ *===========================================================================*/
PRIVATE void siaint(type)
int type; /* interrupt type */
{
}
#endif /* MACHINE == ATARI */
-/*==========================================================================*
- * in_int *
- *==========================================================================*/
+/*===========================================================================*
+ * in_int *
+ *===========================================================================*/
PRIVATE void in_int(rs)
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 */
{
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 */
{
}
}
-/*==========================================================================*
+/*===========================================================================*
* out_int *
- *==========================================================================*/
+ *===========================================================================*/
PRIVATE void out_int(rs)
register rs232_t *rs; /* line with output interrupt */
{
* ---------------------------------------------------------------------------
* | HARD_INT | | | | | | |
* |-------------+---------+---------+---------+---------+---------+---------|
- * | SYS_SIG | sig set | | | | | |
+ * | SYS_SIG | sig set | | | | | |
* |-------------+---------+---------+---------+---------+---------+---------|
* | DEV_READ |minor dev| proc nr | count | O_NONBLOCK| buf ptr |
* |-------------+---------+---------+---------+---------+---------+---------|
/* ...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 */
}
}
}
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);
}
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;
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;
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
}
return(ch | (len << IN_LSHIFT));
}
-/*==========================================================================*
- * rawecho *
- *==========================================================================*/
+/*===========================================================================*
+ * rawecho *
+ *===========================================================================*/
PRIVATE void rawecho(tp, ch)
register tty_t *tp;
int ch;
tp->tty_reprint = rp;
}
-/*==========================================================================*
- * back_over *
- *==========================================================================*/
+/*===========================================================================*
+ * back_over *
+ *===========================================================================*/
PRIVATE int back_over(tp)
register tty_t *tp;
{
return(1); /* one character erased */
}
-/*==========================================================================*
- * reprint *
- *==========================================================================*/
+/*===========================================================================*
+ * reprint *
+ *===========================================================================*/
PRIVATE void reprint(tp)
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 */
}
}
-/*==========================================================================*
- * tty_icancel *
- *==========================================================================*/
+/*===========================================================================*
+ * tty_icancel *
+ *===========================================================================*/
PRIVATE void tty_icancel(tp)
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. */
#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. */
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
}
}
-/*==========================================================================*
- * tty_devnop *
- *==========================================================================*/
+/*===========================================================================*
+ * tty_devnop *
+ *===========================================================================*/
PUBLIC int tty_devnop(tp, try)
tty_t *tp;
int try;
}
/*===========================================================================*
- * do_select *
+ * do_select *
*===========================================================================*/
PRIVATE void do_select(tp, m_ptr)
register tty_t *tp; /* pointer to tty struct */
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;
}
#include <timers.h>
/* 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 */
_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 */
/* 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) );
/* 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 */