]> 4ch.mooo.com Git - 16.git/blob - src/lib/doslib/hw/parport/parport.h
added a bunch of things~ and midi stuff~
[16.git] / src / lib / doslib / hw / parport / parport.h
1 /* WARNING: As usual for performance reasons this library generally does not
2  *          enable/disable interrupts (cli/sti). To avoid contention with
3  *          interrupt handlers the calling program should do that. */
4
5 #include <conio.h> /* this is where Open Watcom hides the outp() etc. functions */
6
7 #include <hw/cpu/cpu.h>
8 #include <stdint.h>
9
10 /* parallel port types */
11 enum {
12         PARPORT_STANDARD=0,
13         PARPORT_BIDIRECTIONAL,
14         PARPORT_ECP,
15         PARPORT_EPP,
16         PARPORT_ECP_AND_EPP,
17         PARPORT_MAX
18 };
19
20 /* modes modes */
21 enum {
22         PARPORT_MODE_STANDARD_STROBE_ACK=0,     /* not on busy, pulse, wait for ack */
23         PARPORT_MODE_STANDARD_STROBE,           /* not on busy, pulse, don't wait for ack */
24         PARPORT_MODE_FIFO,                      /* switch into FIFO mode, let h/w do handshaking */
25         PARPORT_MODE_ECP,                       /* switch to ECP mode */
26         PARPORT_MODE_EPP                        /* switch to EPP mode */
27 };
28
29 #define MAX_PARPORTS            4
30
31 #define PARPORT_SUPPORTS_EPP(x)         ((x) == PARPORT_EPP || (x) == PARPORT_ECP_AND_EPP)
32 #define PARPORT_SUPPORTS_ECP(x)         ((x) == PARPORT_ECP || (x) == PARPORT_ECP_AND_EPP)
33
34 #define PARPORT_IO_DATA                 0
35 #define PARPORT_IO_STATUS               1
36 #define PARPORT_IO_CONTROL              2
37 #define PARPORT_IO_EPP_ADDRESS          3
38 #define PARPORT_IO_EPP_DATA             4
39
40 #define PARPORT_IO_ECP_REG_A            0x400
41 #define PARPORT_IO_ECP_REG_B            0x401
42 #define PARPORT_IO_ECP_CONTROL          0x402
43
44 #define PARPORT_STATUS_nBUSY            (1 << 7)
45 #define PARPORT_STATUS_nACK             (1 << 6)
46 #define PARPORT_STATUS_PAPER_OUT        (1 << 5)
47 #define PARPORT_STATUS_SELECT           (1 << 4)
48 #define PARPORT_STATUS_nERROR           (1 << 3)
49
50 #define PARPORT_CTL_ENABLE_BIDIR        (1 << 5)
51 #define PARPORT_CTL_ENABLE_IRQ          (1 << 4)
52 #define PARPORT_CTL_SELECT_PRINTER      (1 << 3)
53 #define PARPORT_CTL_nINIT               (1 << 2)
54 #define PARPORT_CTL_LINEFEED            (1 << 1)
55 #define PARPORT_CTL_STROBE              (1 << 0)
56
57 #define STANDARD_PARPORT_PORTS          3
58
59 struct info_parport {
60         uint16_t                port;
61         /* 8 bits { */
62         uint8_t                 type:4;
63         uint8_t                 bit10:1;
64         uint8_t                 max_xfer_size:3;        /* in bytes */
65         /* } */
66         int8_t                  irq;
67         int8_t                  dma;
68         /* mode */
69         uint8_t                 output_mode:3;
70         uint8_t                 reserved:5;
71 };
72
73 extern const char *                     parport_type_str[PARPORT_MAX];
74 extern int                              init_parports;
75 extern int                              bios_parports;
76 extern uint16_t                         standard_parport_ports[STANDARD_PARPORT_PORTS];
77 extern struct info_parport              info_parport[MAX_PARPORTS];
78 extern int                              info_parports;
79
80 uint16_t get_bios_parport(unsigned int index);
81 int already_got_parport(uint16_t port);
82 int probe_parport(uint16_t port);
83 int add_pnp_parport(uint16_t port,int irq,int dma,int type);
84 int init_parport();
85