Merge branch 'stage6' of https://github.com/RWTH-OS/eduOS into stage6

Conflicts:
	Makefile.example
	arch/x86/kernel/uart.c
This commit is contained in:
Stefan Lankes 2014-12-19 22:05:15 +01:00
commit 0192f70338
3 changed files with 49 additions and 12 deletions

View file

@ -1,4 +1,4 @@
TERN = xterm
TERM = xterm
TOPDIR = $(shell pwd)
ARCH = x86
NAME = eduos
@ -30,12 +30,17 @@ QEMU = qemu-system-i386
QEMUFLAGS = -smp 2 -monitor stdio \
-net nic,model=rtl8139 \
-net user,hostfwd=tcp::12345-:7
QEMUDEBUGFLAGS = -monitor none -daemonize \
-net nic,model=rtl8139 \
-net user,hostfwd=tcp::12345-:7
QEMUSERIALFLAGS = -device pci-serial,chardev=tS0 \
-chardev socket,host=localhost,port=4555,server,id=tS0
INCLUDE = -I$(TOPDIR)/include -I$(TOPDIR)/arch/$(ARCH)/include
# Compiler options for final code
CFLAGS = -g -m32 -march=i586 -Wall -O2 -fno-builtin -fstrength-reduce -fomit-frame-pointer -finline-functions -nostdinc $(INCLUDE) -fno-stack-protector
# Compiler options for debugging
#CFLAGS = -g -O -m32 -march=i586 -Wall -fno-builtin -DWITH_FRAME_POINTER -nostdinc $(INCLUDE) -fno-stack-protector
debug debug-eclipse : CFLAGS = -g -O0 -m32 -march=i586 -Wall -fno-builtin -DWITH_FRAME_POINTER -nostdinc $(INCLUDE) -fno-stack-protector
AR = ar
ARFLAGS = rsv
RM = rm -rf
@ -58,8 +63,8 @@ $(NAME).elf:
$Q$(LD_FOR_TARGET) $(LDFLAGS) -o $(NAME).elf $^
@echo [OBJCOPY] $(NAME).sym
$Q$(OBJCOPY_FOR_TARGET) $(KEEP_DEBUG) $(NAME).elf $(NAME).sym
@echo [OBJCOPY] $(NAME).elf
$Q$(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $(NAME).elf
#@echo [OBJCOPY] $(NAME).elf
#$Q$(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $(NAME).elf
clean:
$Q$(RM) $(NAME).elf $(NAME).sym *~
@ -73,11 +78,15 @@ qemu: $(NAME).elf
$(QEMU) $(QEMUFLAGS) -kernel $(NAME).elf
uart: $(NAME).elf
$(QEMU) -chardev socket,id=tS0,port=4555,host=localhost,server -device pci-serial,chardev=tS0 $(QEMUFLAGS) -kernel $(NAME).elf
$(QEMU) $(QEMUFLAGS) $(QEMUSERIALFLAGS) -kernel $(NAME).elf
debug: $(NAME).elf
$(TERM) -e $(GDB) $(GDBFLAGS) &
$(QEMU) $(QEMUFLAGS) -s -S -kernel $(NAME).elf
$(QEMU) $(QEMUDEBUGFLAGS) -s -S -kernel $(NAME).elf
debug-eclipse: clean $(NAME).elf
killall $(QEMU) &
( ( $(QEMU) $(QEMUDEBUGFLAGS) $(QEMUSERIALFLAGS) -s -S -kernel $(NAME).elf & ) & )
doc:
@echo Create documentation...

View file

@ -52,6 +52,7 @@
#define UART_DLL 0 /* Out: Divisor Latch Low */
#define UART_DLM 1 /* Out: Divisor Latch High */
#define UART_LCR 3 /* Out: Line Control Register */
#define UART_LSR 5 /* Line Status Register */
#define UART_IER_MSI 0x08 /* Enable Modem status interrupt */
#define UART_IER_RLSI 0x04 /* Enable receiver line status interrupt */
@ -69,7 +70,11 @@
#define UART_FCR_CLEAR_RCVR 0x02 /* Clear the RCVR FIFO */
#define UART_FCR_CLEAR_XMIT 0x04 /* Clear the XMIT FIFO */
#define UART_FCR_TRIGGER_MASK 0xC0 /* Mask for the FIFO trigger range */
#define UART_FCR_TRIGGER_1 0x00 /* Mask for trigger set at 1 */
#define UART_FCR_TRIGGER_1 0x00 /* Trigger RDI at FIFO level 1 byte */
#define UART_FCR_TRIGGER_4 0x40 /* Trigger RDI at FIFO level 4 byte */
#define UART_FCR_TRIGGER_8 0x80 /* Trigger RDI at FIFO level 8 byte */
#define UART_FCR_TRIGGER_14 0xc0 /* Trigger RDI at FIFO level 14 byte*/
#define UART_LCR_DLAB 0x80 /* Divisor latch access bit */
#define UART_LCR_SBC 0x40 /* Set break control */
@ -156,8 +161,25 @@ static void uart_handler(struct state *s)
c = uart_getchar();
mailbox_uint8_post(&input_queue, c);
goto out;
}
if(c & UART_IIR_THRI) {
// acknowledge interrupt
c = read_from_uart(UART_IIR);
goto out;
}
if(c & UART_IIR_RLSI) {
// acknowledge interrupt
c = read_from_uart(UART_LSR);
goto out;
}
out:
c = read_from_uart(UART_IIR);
}
}
@ -215,7 +237,7 @@ static void uart_config(void)
write_to_uart(UART_LCR, lcr & (~UART_LCR_DLAB));
/* enable interrupt */
write_to_uart(UART_IER, UART_IER_RDI /*| UART_IER_RLSI | UART_IER_THRI*/);
write_to_uart(UART_IER, UART_IER_RDI | UART_IER_RLSI | UART_IER_THRI);
int err = create_kernel_task(&id, uart_thread, NULL, HIGH_PRIO);
if (BUILTIN_EXPECT(err, 0))
@ -236,6 +258,12 @@ int uart_init(void)
// Searching for Qemu's UART device
if (pci_get_device_info(0x1b36, 0x0002, &pci_info) == 0)
goto Lsuccess;
// Searching for Qemu's 2x UART device (pci-serial-2x)
if (pci_get_device_info(0x1b36, 0x0003, &pci_info) == 0)
goto Lsuccess;
// Searching for Qemu's 4x UART device (pci-serial-4x)
if (pci_get_device_info(0x1b36, 0x0003, &pci_info) == 0)
goto Lsuccess;
return -1;
@ -250,9 +278,6 @@ Lsuccess:
page_map(iobase & PAGE_MASK, iobase & PAGE_MASK, 1, PG_GLOBAL | PG_RW | PG_PCD);
kprintf("UART uses mmio address 0x%x\n", iobase);
}
// configure uart
uart_config();
#else
// per default we use COM1...
mmio = 0;
@ -260,6 +285,9 @@ Lsuccess:
irq_install_handler(32+4, uart_handler);
#endif
// configure uart
uart_config();
return 0;
}

View file

@ -1,5 +1,5 @@
# Constant part of the script
symbol-file eduos.sym
symbol-file eduos.elf
target remote localhost:1234
set architecture i386