| // Intel 8250 serial port (UART). | |
| static int uart; // is there a uart? | |
| void | |
| uartinit(void) | |
| { | |
| char *p; | |
| // Turn off the FIFO | |
| outb(COM1+2, 0); | |
| // 9600 baud, 8 data bits, 1 stop bit, parity off. | |
| outb(COM1+3, 0x80); // Unlock divisor | |
| outb(COM1+0, 115200/9600); | |
| outb(COM1+1, 0); | |
| outb(COM1+3, 0x03); // Lock divisor, 8 data bits. | |
| outb(COM1+4, 0); | |
| outb(COM1+1, 0x01); // Enable receive interrupts. | |
| // If status is 0xFF, no serial port. | |
| if(inb(COM1+5) == 0xFF) | |
| return; | |
| uart = 1; | |
| // Acknowledge pre-existing interrupt conditions; | |
| // enable interrupts. | |
| inb(COM1+2); | |
| inb(COM1+0); | |
| ioapicenable(IRQ_COM1, 0); | |
| // Announce that we're here. | |
| for(p="xv6...\n"; *p; p++) | |
| uartputc(*p); | |
| } | |
| void | |
| uartputc(int c) | |
| { | |
| int i; | |
| if(!uart) | |
| return; | |
| for(i = 0; i < 128 && !(inb(COM1+5) & 0x20); i++) | |
| microdelay(10); | |
| outb(COM1+0, c); | |
| } | |
| static int | |
| uartgetc(void) | |
| { | |
| if(!uart) | |
| return -1; | |
| if(!(inb(COM1+5) & 0x01)) | |
| return -1; | |
| return inb(COM1+0); | |
| } | |
| void | |
| uartintr(void) | |
| { | |
| consoleintr(uartgetc); | |
| } | |
Xet Storage Details
- Size:
- 1.29 kB
- Xet hash:
- 2eecba9dd0ed6fa6ef603c7c8d976f9c29f197f4cd5fa3dde42b05d093a199ae
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.