. add checks to printer driver kernel calls
. correct some i/o locations for printer in drivers.conf
This commit is contained in:
parent
03446f5554
commit
a80365f407
3 changed files with 49 additions and 23 deletions
|
@ -21,7 +21,7 @@ OBJ = printer.o
|
||||||
all build: $(DRIVER)
|
all build: $(DRIVER)
|
||||||
$(DRIVER): $(OBJ)
|
$(DRIVER): $(OBJ)
|
||||||
$(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBS)
|
$(CC) -o $@ $(LDFLAGS) $(OBJ) $(LIBS)
|
||||||
install -S 8k $(DRIVER)
|
install $(DRIVER)
|
||||||
|
|
||||||
# install with other drivers
|
# install with other drivers
|
||||||
install: /usr/sbin/$(DRIVER)
|
install: /usr/sbin/$(DRIVER)
|
||||||
|
|
|
@ -208,13 +208,16 @@ int safe; /* use virtual addresses or grant id's? */
|
||||||
|
|
||||||
retries = MAX_ONLINE_RETRIES + 1;
|
retries = MAX_ONLINE_RETRIES + 1;
|
||||||
while (--retries > 0) {
|
while (--retries > 0) {
|
||||||
sys_inb(port_base + 1, &status);
|
if(sys_inb(port_base + 1, &status) != OK) {
|
||||||
|
printf("printer: sys_inb of %x failed\n", port_base+1);
|
||||||
|
panic(__FILE__,"sys_inb failed", NO_NUM);
|
||||||
|
}
|
||||||
if ((status & ON_LINE)) { /* printer online! */
|
if ((status & ON_LINE)) { /* printer online! */
|
||||||
prepare_output();
|
prepare_output();
|
||||||
do_printer_output();
|
do_printer_output();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tickdelay(30); /* wait before retry */
|
tickdelay(HZ/2); /* wait before retry */
|
||||||
}
|
}
|
||||||
/* If we reach this point, the printer was not online in time. */
|
/* If we reach this point, the printer was not online in time. */
|
||||||
done_status = status;
|
done_status = status;
|
||||||
|
@ -331,16 +334,24 @@ PRIVATE void do_initialize()
|
||||||
initialized = TRUE;
|
initialized = TRUE;
|
||||||
|
|
||||||
/* Get the base port for first printer. */
|
/* Get the base port for first printer. */
|
||||||
sys_vircopy(SELF, BIOS_SEG, LPT1_IO_PORT_ADDR,
|
if(sys_vircopy(SELF, BIOS_SEG, LPT1_IO_PORT_ADDR,
|
||||||
SELF, D, (vir_bytes) &port_base, LPT1_IO_PORT_SIZE);
|
SELF, D, (vir_bytes) &port_base, LPT1_IO_PORT_SIZE) != OK) {
|
||||||
sys_outb(port_base + 2, INIT_PRINTER);
|
panic(__FILE__, "do_initialize: sys_vircopy failed", NO_NUM);
|
||||||
tickdelay(1); /* easily satisfies Centronics minimum */
|
}
|
||||||
/* was 2 millisecs; now is ~17 millisecs */
|
if(sys_outb(port_base + 2, INIT_PRINTER) != OK) {
|
||||||
sys_outb(port_base + 2, PR_SELECT);
|
printf("printer: sys_outb of %x failed\n", port_base+2);
|
||||||
|
panic(__FILE__, "do_initialize: sys_outb init failed", NO_NUM);
|
||||||
|
}
|
||||||
|
tickdelay(HZ/20); /* easily satisfies Centronics minimum */
|
||||||
|
if(sys_outb(port_base + 2, PR_SELECT) != OK) {
|
||||||
|
printf("printer: sys_outb of %x failed\n", port_base+2);
|
||||||
|
panic(__FILE__, "do_initialize: sys_outb select failed", NO_NUM);
|
||||||
|
}
|
||||||
irq_hook_id = 0;
|
irq_hook_id = 0;
|
||||||
sys_irqsetpolicy(PRINTER_IRQ, 0, &irq_hook_id);
|
if(sys_irqsetpolicy(PRINTER_IRQ, 0, &irq_hook_id) != OK ||
|
||||||
sys_irqenable(&irq_hook_id);
|
sys_irqenable(&irq_hook_id) != OK) {
|
||||||
|
panic(__FILE__, "do_initialize: irq enabling failed", NO_NUM);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*==========================================================================*
|
/*==========================================================================*
|
||||||
|
@ -389,8 +400,13 @@ PRIVATE void do_printer_output()
|
||||||
* when the printer is busy with a previous character, because the
|
* when the printer is busy with a previous character, because the
|
||||||
* interrupt status does not affect the printer.
|
* interrupt status does not affect the printer.
|
||||||
*/
|
*/
|
||||||
sys_outb(port_base + 2, PR_SELECT);
|
if(sys_outb(port_base + 2, PR_SELECT) != OK) {
|
||||||
sys_irqenable(&irq_hook_id);
|
printf("printer: sys_outb of %x failed\n", port_base+2);
|
||||||
|
panic(__FILE__,"sys_outb failed", NO_NUM);
|
||||||
|
}
|
||||||
|
if(sys_irqenable(&irq_hook_id) != OK) {
|
||||||
|
panic(__FILE__,"sys_irqenable failed", NO_NUM);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -398,7 +414,10 @@ PRIVATE void do_printer_output()
|
||||||
/* Loop to handle fast (buffered) printers. It is important that
|
/* Loop to handle fast (buffered) printers. It is important that
|
||||||
* processor interrupts are not disabled here, just printer interrupts.
|
* processor interrupts are not disabled here, just printer interrupts.
|
||||||
*/
|
*/
|
||||||
(void) sys_inb(port_base + 1, &status);
|
if(sys_inb(port_base + 1, &status) != OK) {
|
||||||
|
printf("printer: sys_inb of %x failed\n", port_base+1);
|
||||||
|
panic(__FILE__,"sys_inb failed", NO_NUM);
|
||||||
|
}
|
||||||
if ((status & STATUS_MASK) == BUSY_STATUS) {
|
if ((status & STATUS_MASK) == BUSY_STATUS) {
|
||||||
/* Still busy with last output. This normally happens
|
/* Still busy with last output. This normally happens
|
||||||
* immediately after doing output to an unbuffered or slow
|
* immediately after doing output to an unbuffered or slow
|
||||||
|
@ -406,7 +425,9 @@ PRIVATE void do_printer_output()
|
||||||
* pr_restart, since they are not synchronized with printer
|
* pr_restart, since they are not synchronized with printer
|
||||||
* interrupts. It may happen after a spurious interrupt.
|
* interrupts. It may happen after a spurious interrupt.
|
||||||
*/
|
*/
|
||||||
sys_irqenable(&irq_hook_id);
|
if(sys_irqenable(&irq_hook_id) != OK) {
|
||||||
|
panic(__FILE__, "sys_irqenable failed\n", NO_NUM);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((status & STATUS_MASK) == NORMAL_STATUS) {
|
if ((status & STATUS_MASK) == NORMAL_STATUS) {
|
||||||
|
@ -414,7 +435,10 @@ PRIVATE void do_printer_output()
|
||||||
pv_set(char_out[0], port_base, *optr++);
|
pv_set(char_out[0], port_base, *optr++);
|
||||||
pv_set(char_out[1], port_base+2, ASSERT_STROBE);
|
pv_set(char_out[1], port_base+2, ASSERT_STROBE);
|
||||||
pv_set(char_out[2], port_base+2, NEGATE_STROBE);
|
pv_set(char_out[2], port_base+2, NEGATE_STROBE);
|
||||||
sys_voutb(char_out, 3); /* request series of port outb */
|
if(sys_voutb(char_out, 3) != OK) {
|
||||||
|
/* request series of port outb */
|
||||||
|
panic(__FILE__, "sys_voutb failed\n", NO_NUM);
|
||||||
|
}
|
||||||
|
|
||||||
user_vir_d++;
|
user_vir_d++;
|
||||||
user_left--;
|
user_left--;
|
||||||
|
@ -422,7 +446,9 @@ PRIVATE void do_printer_output()
|
||||||
/* Error. This would be better ignored (treat as busy). */
|
/* Error. This would be better ignored (treat as busy). */
|
||||||
done_status = status;
|
done_status = status;
|
||||||
output_done();
|
output_done();
|
||||||
sys_irqenable(&irq_hook_id);
|
if(sys_irqenable(&irq_hook_id) != OK) {
|
||||||
|
panic(__FILE__, "sys_irqenable failed\n", NO_NUM);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -431,6 +457,8 @@ PRIVATE void do_printer_output()
|
||||||
/* Finished printing chunk OK. */
|
/* Finished printing chunk OK. */
|
||||||
done_status = OK;
|
done_status = OK;
|
||||||
output_done();
|
output_done();
|
||||||
sys_irqenable(&irq_hook_id);
|
if(sys_irqenable(&irq_hook_id) != OK) {
|
||||||
|
panic(__FILE__, "sys_irqenable failed\n", NO_NUM);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -187,10 +187,8 @@ driver mfs
|
||||||
|
|
||||||
driver printer
|
driver printer
|
||||||
{
|
{
|
||||||
io 408:2 # LPT1
|
io 378:4 # LPT1
|
||||||
40a:2 # LPT2
|
278:4 # LPT2
|
||||||
40c:2 # LPT3
|
|
||||||
40e:2 # LPT4
|
|
||||||
;
|
;
|
||||||
irq
|
irq
|
||||||
7 # PRINTER_IRQ
|
7 # PRINTER_IRQ
|
||||||
|
|
Loading…
Reference in a new issue