Permalink
Browse files

UART is now a kernel module.

  • Loading branch information...
1 parent ad55400 commit 503189e45c10b727cbf8e84ddee56d2d0020d142 @duckinator committed Aug 1, 2012
Showing with 31 additions and 6 deletions.
  1. +4 −0 Makefile
  2. +2 −0 isofs/boot/grub/menu.lst
  3. +2 −1 makeiso.sh
  4. +5 −1 modules.mk
  5. +3 −1 src/metodo/hal/hal.c
  6. +15 −3 src/{metodo/driver → modules}/serial.c
View
@@ -59,6 +59,10 @@ libc.lib: $(filter src/lib/libc/%.o, ${OBJFILES})
@${AR} rc src/lib/libc/libc.lib $^
@${RANLIB} src/lib/libc/libc.lib
+hal.lib: $(filter src/metodo/hal/%.o, ${OBJFILES})
+ @${AR} rc src/metodo/hal/hal.lib $^
+ @${RANLIB} src/metodo/hal/hal.lib
+
-include $(find ./src -name '*.d')
%.o: %.c
View
@@ -10,10 +10,12 @@ module /System/userland.exe
title Metodo Dux with all modules (no userland)
kernel /System/metodo.exe
+module /Modules/serial.exe
module /Modules/test_module.exe
title Metodo Dux with all modules and Userland
kernel /System/metodo.exe
module /System/userland.exe
+module /Modules/serial.exe
module /Modules/test_module.exe
View
@@ -20,7 +20,8 @@ for x in `find src -name '*.lib'`; do
cp $x isofs/System
done
-for x in `find src/module -name '*.exe'`; do
+for x in `find src/modules -name '*.exe'`; do
+ echo "Copying $x"
cp $x isofs/Modules
done
View
@@ -1,7 +1,11 @@
-modules: metodo.exe test_module.exe
+# TODO: Make this not have to manually specify each module...
+
+modules: metodo.exe test_module.exe serial.exe
@mkdir -p isofs/Modules
@cp src/modules/test_module.exe isofs/Modules/
test_module.exe: krnllib.lib libc.lib src/modules/test_module.o
@${LD} -o src/modules/test_module.exe ${LDFLAGS} -Ttext 0x200000 src/modules/test_module.o -Lsrc/lib/krnllib src/lib/krnllib/krnllib.lib -Lsrc/lib/libc src/lib/libc/libc.lib
+serial.exe: krnllib.lib libc.lib hal.lib src/modules/serial.o
+ @${LD} -o src/modules/serial.exe ${LDFLAGS} -Ttext 0x200000 src/modules/serial.o -Lsrc/lib/krnllib src/lib/krnllib/krnllib.lib -Lsrc/lib/libc src/lib/libc/libc.lib -Lsrc/metodo/hal src/metodo/hal/hal.lib
View
@@ -2,6 +2,8 @@
#include <metodo/core/scheduler.h>
#include <string.h>
+//#include <driver/serial.h>
+
void StartService(const char *msg, const char *name, void (*func)())
{
size_t i;
@@ -32,7 +34,7 @@ void HalInit(void) {
StartInitializer("memory management", &init_mm);
StartInitializer("keyboard", &HalKeyboardInit);
//StartInitializer("scheduler", &HalSchedulerEnable);
- StartInitializer("UART", &HalKeyboardInit);
+ //StartInitializer("UART", &UartInit);
StartService("Enabling", "interrupts", &HalEnableInterrupts);
}
@@ -1,9 +1,12 @@
-
/*
* This code is based on information from
* http://www.nondot.org/sabre/os/files/Communication/ser_port.txt
*/
+#include <module.h>
+#include <lib/krnllib.h>
+#include <system.h>
+
#include <driver/serial.h>
//DRIVER_INIT(UartInit)
@@ -16,6 +19,13 @@ void UartSend(char c)
UartSend_int(c);
}
+void UartSendString(char *str)
+{
+ do {
+ UartSend(*str);
+ } while (*str++);
+}
+
static void UartSend_int(char c)
{
/* wait until UART is ready to send */
@@ -24,18 +34,20 @@ static void UartSend_int(char c)
HalOutPort(UART_BASE_REGISTER, (uint8_t)c);
}
-int UartInit()
+MODULE(Uart)
{
HalOutPort(UART_BASE_REGISTER + LineControl, DLAB);
HalOutPort(UART_BASE_REGISTER, UART_BAUDRATE_DIVISOR);
HalOutPort(UART_BASE_REGISTER + LineControl, UART_LCR);
HalOutPort(UART_BASE_REGISTER + ModemControl, 0);
+ UartSendString("UART successfully enabled.\n");
+
return 0;
}
struct DisplayDevice UartDisplayDevice = {
- .Init = (void*)UartInit,
+ .Init = (void*)Uart__ModuleInit,
.DisplayChar = (void*)UartSend,
.DisplayClear = NULL, /* nothing, for now */
};

0 comments on commit 503189e

Please sign in to comment.