make vfs & filesystems use failable copying
[minix3.git] / kernel / arch / i386 / oxpcie.c
blob4b87f6c10c924f63c630bf13e1950f4c94fec097
2 #include "kernel/kernel.h"
4 #if CONFIG_OXPCIE
6 /* Documentation is at http://www.plxtech.com/products/uart/oxpcie952 */
8 #include "oxpcie.h"
9 #include "serial.h"
11 static unsigned char *oxpcie_vaddr = NULL;
13 void oxpcie_set_vaddr(unsigned char *vaddr)
15 oxpcie_vaddr = vaddr;
18 static void oxpcie_init(void)
20 printf("oxpcie_init\n");
21 /* Enable access to EFR and DLM+DLL */
22 OXPCIE_LCR = 0xBF;
24 /* Set FICR[1] to increase FIFO */
25 OXPCIE_FICR = 0x01;
27 /* Set enhanced mode [4]
28 * no RTS/CTS [7:6]
29 * no special char detection [5]
30 * no in-band receive flow control [1:0]
31 * no in-band transmit flow control [3:2]
33 OXPCIE_EFR = 0x10;
35 /* Set divisor register to 115200 baud. */
36 OXPCIE_DLM = 0x00;
37 OXPCIE_DLL = 0x22;
39 /* Forget DLM and DLL, set LCR to config. */
40 OXPCIE_LCR = LCR_CONFIG;
41 OXPCIE_LCR = LCR_CONFIG;
43 OXPCIE_TCR = 0x01;
44 OXPCIE_CPR = 0x20;
45 OXPCIE_CPR2 = 0;
48 void oxpcie_putc(char c)
50 static int inuse = 0;
52 if(vm_running && oxpcie_vaddr && !inuse) {
53 int i;
54 static int init_done;
55 inuse = 1;
57 if(!init_done) {
58 oxpcie_init();
59 init_done = 1;
62 for (i= 0; i<100000; i++) {
63 if(OXPCIE_LSR & LSR_THRE)
64 break;
66 OXPCIE_THR = c;
67 inuse = 0;
71 int oxpcie_in(void)
73 if(vm_running && oxpcie_vaddr) {
74 int lsr;
75 lsr = OXPCIE_LSR;
76 if(lsr & LSR_DR)
77 return (int) OXPCIE_RBR;
80 return -1;
83 #endif