]> 4ch.mooo.com Git - 16.git/blob - src/lib/doslib/hw/parport/test.c
added a bunch of things~ and midi stuff~
[16.git] / src / lib / doslib / hw / parport / test.c
1
2 #include <stdio.h>
3 #include <conio.h> /* this is where Open Watcom hides the outp() etc. functions */
4 #include <stdlib.h>
5 #include <string.h>
6 #include <unistd.h>
7 #include <assert.h>
8 #include <fcntl.h>
9 #include <dos.h>
10
11 #include <hw/cpu/cpu.h>
12 #include <hw/dos/dos.h>
13 #include <hw/8254/8254.h>
14 #include <hw/8259/8259.h>
15 #include <hw/dos/doswin.h>
16 #include <hw/parport/parport.h>
17
18 #if defined(ISAPNP)
19 #include <hw/isapnp/isapnp.h>
20 #include <hw/parport/parpnp.h>
21 #endif
22
23 int main() {
24         int i;
25
26         printf("PC parallel printer port test program\n");
27 #ifdef ISAPNP
28         printf("ISA Plug & Play version\n");
29 #endif
30
31         cpu_probe();            /* ..for the DOS probe routine */
32         probe_dos();            /* ..for the Windows detection code */
33         detect_windows();       /* Windows virtualizes the LPT ports, and we don't want probing to occur to avoid any disruption */
34
35         if (!probe_8254()) {
36                 printf("8254 not found (I need this for time-sensitive portions of the driver)\n");
37                 return 1;
38         }
39
40         if (!probe_8259()) {
41                 printf("8259 not found (I need this for portions of the test involving serial interrupts)\n");
42                 return 1;
43         }
44
45         if (!init_parport()) {
46                 printf("Cannot init parport library\n");
47                 return 1;
48         }
49
50 #ifdef ISAPNP
51         if (!init_isa_pnp_bios()) {
52                 printf("Cannot init ISA PnP\n");
53                 return 1;
54         }
55         if (find_isa_pnp_bios()) pnp_parport_scan();
56         else printf("Warning, ISA PnP BIOS not found\n");
57 #else
58         printf("Probing BIOS-listed locations ");
59         for (i=0;i < bios_parports;i++) {
60                 uint16_t port = get_bios_parport(i);
61                 printf("%03x ",port);
62                 if (probe_parport(port)) printf("[OK] ");
63                 fflush(stdout);
64         }
65         printf("\n");
66
67         printf("Probing standard port locations ");
68         for (i=0;i < STANDARD_PARPORT_PORTS;i++) {
69                 uint16_t port = standard_parport_ports[i];
70                 printf("%03x ",port);
71                 if (probe_parport(port)) printf("[OK] ");
72                 fflush(stdout);
73         }
74         printf("\n");
75 #endif
76
77         printf("Found parallel ports:\n");
78         for (i=0;i < info_parports;i++) {
79                 struct info_parport *prt = &info_parport[i];
80                 printf(" [%u] port=0x%04x IRQ=%d DMA=%d 10-bit=%u max-xfer-size=%u type='%s'\n",i+1,prt->port,prt->irq,prt->dma,prt->bit10,prt->max_xfer_size,parport_type_str[prt->type]);
81         }
82
83         return 0;
84 }
85