Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Part 7, Input Driver

  • Loading branch information...
commit 6aa2baea984736cf2b9fccab4b076f62dcbf5f33 1 parent e32cd57
@singpolyma authored
Showing with 26 additions and 2 deletions.
  1. +21 −2 kernel.c
  2. +5 −0 versatilepb.h
View
23 kernel.c
@@ -34,7 +34,7 @@ void bwputs(char *s) {
}
#define STACK_SIZE 1024 /* Size of task stacks in words */
-#define TASK_LIMIT 3 /* Max number of tasks we can handle */
+#define TASK_LIMIT 10 /* Max number of tasks we can handle */
#define PIPE_BUF 512 /* Size of largest atomic pipe message */
#define PATH_MAX 255 /* Longest absolute path */
#define PIPE_LIMIT (TASK_LIMIT*5)
@@ -138,14 +138,33 @@ void serialout(volatile unsigned int* uart, unsigned int intr) {
doread = 1;
}
interrupt_wait(intr);
+ *(uart + UARTICR) = UARTICR_TXIC;
}
}
-void first(void) {
+void serialin(volatile unsigned int* uart, unsigned int intr) {
int fd;
+ char c;
+ mkfifo("/dev/tty0/in", 0);
+ fd = open("/dev/tty0/in", 0);
+
+ /* enable RX interrupt on UART */
+ *(uart + UARTIMSC) |= UARTIMSC_RXIM;
+
+ while(1) {
+ interrupt_wait(intr);
+ *(uart + UARTICR) = UARTICR_RXIC;
+ if(!(*(uart + UARTFR) & UARTFR_RXFE)) {
+ c = *uart;
+ write(fd, &c, 1);
+ }
+ }
+}
+void first(void) {
if(!fork()) pathserver();
if(!fork()) serialout(UART0, PIC_UART0);
+ if(!fork()) serialin(UART0, PIC_UART0);
fd = open("/dev/tty0/out", 0);
write(fd, "woo\n", sizeof("woo\n"));
View
5 versatilepb.h
@@ -3,8 +3,13 @@
/* http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0183g/I18381.html */
#define UARTFR 0x06 /* 0x18 bytes */
#define UARTIMSC 0x0E /* 0x38 bytes */
+#define UARTICR 0x11 /* 0x44 bytes */
+#define UARTFR_RXFE 0x10
#define UARTFR_TXFF 0x20
+#define UARTIMSC_RXIM 0x10
#define UARTIMSC_TXIM 0x20
+#define UARTICR_RXIC 0x10
+#define UARTICR_TXIC 0x20
/* http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0271d/index.html */
#define TIMER0 ((volatile unsigned int*)0x101E2000)
Please sign in to comment.
Something went wrong with that request. Please try again.