diff options
| -rw-r--r-- | Makefile | 1 | ||||
| -rw-r--r-- | asm/asm_int.h (renamed from asm/int.h) | 0 | ||||
| -rw-r--r-- | asm/asm_int.s (renamed from asm/int.s) | 0 | ||||
| -rw-r--r-- | asm/asm_pic.asm (renamed from asm/pic.asm) | 0 | ||||
| -rw-r--r-- | asm/asm_pic.h (renamed from asm/pic.h) | 0 | ||||
| -rw-r--r-- | asm/asm_pit.h (renamed from asm/pit.h) | 0 | ||||
| -rw-r--r-- | asm/asm_pit.s (renamed from asm/pit.s) | 0 | ||||
| -rw-r--r-- | asm/asm_start.h (renamed from asm/start.h) | 0 | ||||
| -rw-r--r-- | asm/asm_start.s (renamed from asm/start.s) | 0 | ||||
| -rw-r--r-- | asm/asm_task.h (renamed from asm/task.h) | 0 | ||||
| -rw-r--r-- | asm/asm_task.s (renamed from asm/task.s) | 0 | ||||
| -rw-r--r-- | asm/asm_usermode.h (renamed from asm/usermode.h) | 0 | ||||
| -rw-r--r-- | asm/asm_usermode.s (renamed from asm/usermode.s) | 0 | ||||
| -rw-r--r-- | asm/asm_x86.h (renamed from asm/x86.h) | 2 | ||||
| -rw-r--r-- | asm/asm_x86.s (renamed from asm/x86.s) | 11 | ||||
| -rw-r--r-- | driver/keyboard.c | 2 | ||||
| -rw-r--r-- | driver/mouse.c | 2 | ||||
| -rw-r--r-- | driver/pci.c | 2 | ||||
| -rw-r--r-- | driver/serial.c | 2 | ||||
| -rw-r--r-- | driver/timer.c | 2 | ||||
| -rw-r--r-- | kernel/interrupts.c | 6 | ||||
| -rw-r--r-- | kernel/mp.c | 2 | ||||
| -rw-r--r-- | kernel/scheduler.c | 2 | ||||
| -rw-r--r-- | kernel/smp.c | 2 | ||||
| -rw-r--r-- | kernel/spinlock.c | 6 | ||||
| -rw-r--r-- | kernel/spinlock.h | 6 | ||||
| -rw-r--r-- | kernel/vmem.c | 2 | ||||
| -rw-r--r-- | kernel/vmem.h | 2 | ||||
| -rw-r--r-- | linker.ld | 2 | ||||
| -rw-r--r-- | userspace/foolshell.c | 22 |
30 files changed, 48 insertions, 28 deletions
@@ -26,6 +26,7 @@ CFLAGS+=-nostdlib CFLAGS+=-O0 CFLAGS+=-I. CFLAGS+=-I/home/miguel/temp/foolos/usr/i686-foolos/include/ +CFLAGS+=-I./asm CFLAGS+=-gstabs #CFLAGS+=-fstack-protector-all diff --git a/asm/int.h b/asm/asm_int.h index 4133fbf..4133fbf 100644 --- a/asm/int.h +++ b/asm/asm_int.h diff --git a/asm/int.s b/asm/asm_int.s index 566b646..566b646 100644 --- a/asm/int.s +++ b/asm/asm_int.s diff --git a/asm/pic.asm b/asm/asm_pic.asm index 901f854..901f854 100644 --- a/asm/pic.asm +++ b/asm/asm_pic.asm diff --git a/asm/pic.h b/asm/asm_pic.h index 0daea2a..0daea2a 100644 --- a/asm/pic.h +++ b/asm/asm_pic.h diff --git a/asm/pit.h b/asm/asm_pit.h index d020de1..d020de1 100644 --- a/asm/pit.h +++ b/asm/asm_pit.h diff --git a/asm/pit.s b/asm/asm_pit.s index 8e16d0b..8e16d0b 100644 --- a/asm/pit.s +++ b/asm/asm_pit.s diff --git a/asm/start.h b/asm/asm_start.h index 4b2db16..4b2db16 100644 --- a/asm/start.h +++ b/asm/asm_start.h diff --git a/asm/start.s b/asm/asm_start.s index ca99c20..ca99c20 100644 --- a/asm/start.s +++ b/asm/asm_start.s diff --git a/asm/task.h b/asm/asm_task.h index 40a8c17..40a8c17 100644 --- a/asm/task.h +++ b/asm/asm_task.h diff --git a/asm/task.s b/asm/asm_task.s index bf80025..bf80025 100644 --- a/asm/task.s +++ b/asm/asm_task.s diff --git a/asm/usermode.h b/asm/asm_usermode.h index 16597f2..16597f2 100644 --- a/asm/usermode.h +++ b/asm/asm_usermode.h diff --git a/asm/usermode.s b/asm/asm_usermode.s index 71ecc1d..71ecc1d 100644 --- a/asm/usermode.s +++ b/asm/asm_usermode.s diff --git a/asm/x86.h b/asm/asm_x86.h index 8e6a741..529a6c2 100644 --- a/asm/x86.h +++ b/asm/asm_x86.h @@ -77,7 +77,7 @@ void x86_cli (); void x86_sti (); /** xchg - this can be used for semaphors and simlar */ -uint8_t x86_xchg (uint8_t *addr, uint8_t val); +uint8_t x86_xchg (uint32_t addr, uint32_t val); /** invlpg - invalidate translation lookaside buffer */ void x86_invlpg(uint32_t addr); diff --git a/asm/x86.s b/asm/asm_x86.s index 3243352..35052b1 100644 --- a/asm/x86.s +++ b/asm/asm_x86.s @@ -121,3 +121,14 @@ set_cr3: set_cr4: mov %eax,%cr4 ret + +x86_xchg: + mov 8(%esp), %eax // addr + mov 4(%esp), %edx // value + xchg %edx, (%eax) //LOCK protocol impemented anyway + ret + +x86_invlpg: + mov 4(%esp), %eax // addr + invlpg (%eax) + ret diff --git a/driver/keyboard.c b/driver/keyboard.c index 65a99da..7cc93ec 100644 --- a/driver/keyboard.c +++ b/driver/keyboard.c @@ -2,7 +2,7 @@ // http://www.computer-engineering.org/ps2keyboard/scancodes1.html -#include "asm/x86.h" +#include "asm_x86.h" #include <stdbool.h> diff --git a/driver/mouse.c b/driver/mouse.c index 958cdc4..ab7ec58 100644 --- a/driver/mouse.c +++ b/driver/mouse.c @@ -7,7 +7,7 @@ #include <stdint.h> -#include "asm/x86.h" +#include "asm_x86.h" static volatile uint8_t mouse_cycle; static volatile uint8_t mouse_byte[3]; diff --git a/driver/pci.c b/driver/pci.c index 4ea01d1..e8d8b23 100644 --- a/driver/pci.c +++ b/driver/pci.c @@ -1,7 +1,7 @@ #include "kernel/kernel.h" -#include "asm/x86.h" +#include "asm_x86.h" #include "e1000.h" #define PCI_CONFIG_DATA 0xCFC diff --git a/driver/serial.c b/driver/serial.c index 32479ae..8a5dd2e 100644 --- a/driver/serial.c +++ b/driver/serial.c @@ -1,6 +1,6 @@ #include "driver/serial.h" -#include "asm/x86.h" // provides x86_inb() and x86_outb() +#include "asm_x86.h" // provides x86_inb() and x86_outb() /** COM1 Port */ static const PORT=0x3f8; diff --git a/driver/timer.c b/driver/timer.c index 88c9931..3a8c31c 100644 --- a/driver/timer.c +++ b/driver/timer.c @@ -1,7 +1,7 @@ #include "timer.h" -#include "asm/x86.h" +#include "asm_x86.h" static volatile uint64_t task_system_clock_start=0; diff --git a/kernel/interrupts.c b/kernel/interrupts.c index 1e209a9..501ccd4 100644 --- a/kernel/interrupts.c +++ b/kernel/interrupts.c @@ -1,9 +1,9 @@ #include "kernel/kernel.h" -#include "asm/int.h" -#include "asm/pit.h" +#include "asm_int.h" +#include "asm_pit.h" #include "driver/mouse.h" #include "interrupts.h" -#include "asm/x86.h" +#include "asm_x86.h" /** The size of our interrupts table */ #define INT_MAX 255 diff --git a/kernel/mp.c b/kernel/mp.c index 5cd58ac..df7549a 100644 --- a/kernel/mp.c +++ b/kernel/mp.c @@ -2,7 +2,7 @@ #include <stdbool.h> -#include "asm/x86.h" +#include "asm_x86.h" #include "smp.h" typedef struct mp_fps_struct diff --git a/kernel/scheduler.c b/kernel/scheduler.c index 5316438..1cbd658 100644 --- a/kernel/scheduler.c +++ b/kernel/scheduler.c @@ -2,7 +2,7 @@ #include "kernel.h" #include "mem.h" -#include "asm/x86.h" +#include "asm_x86.h" #include "kmalloc.h" #include "vmem.h" diff --git a/kernel/smp.c b/kernel/smp.c index 619463a..894dbe0 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -7,7 +7,7 @@ #include "smp.h" #include "mem.h" #include "spinlock.h" -#include "asm/x86.h" +#include "asm_x86.h" #define FOOLOS_APIC_SPUR_INT 0x00f0 #define FOOLOS_APIC_INT_COMMAND_LOW 0x0300 diff --git a/kernel/spinlock.c b/kernel/spinlock.c index bbc68c0..03efa6e 100644 --- a/kernel/spinlock.c +++ b/kernel/spinlock.c @@ -1,11 +1,9 @@ - #include "spinlock.h" #include "kernel.h" -#include "asm/x86.h" +#include "asm_x86.h" -// https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html static volatile uint32_t spinlocks[NUMBER_SPINLOCKS]; @@ -16,13 +14,11 @@ void check_spinlocks() klog("%d",spinlocks[i]); } -/* void lock_spin(uint32_t i) { uint32_t *addr=spinlocks+i; while(x86_xchg(addr,1)); } -*/ void lock_release(uint32_t i) { diff --git a/kernel/spinlock.h b/kernel/spinlock.h index df35e3b..8ce2f57 100644 --- a/kernel/spinlock.h +++ b/kernel/spinlock.h @@ -1,3 +1,9 @@ +/* + * @file + * + * https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html + */ + #ifndef SPINLOCK_H #define SPINLOCK_H diff --git a/kernel/vmem.c b/kernel/vmem.c index 542b3a2..1652a9e 100644 --- a/kernel/vmem.c +++ b/kernel/vmem.c @@ -1,7 +1,7 @@ #include <stdlib.h> #include "kernel.h" -#include "asm/x86.h" +#include "asm_x86.h" #include "mem.h" #include "vmem.h" diff --git a/kernel/vmem.h b/kernel/vmem.h index 8e538bb..3bbda2f 100644 --- a/kernel/vmem.h +++ b/kernel/vmem.h @@ -28,7 +28,7 @@ * .......... User Heap (brk()) | * 0x08000000 User Code | * | - * | almost 100 megs (in kernel alloc/free?) + * | almost 100 megs (in kernel alloc/free private-cpu and shared) * | * 0x02000000 FoolOS TSS Stack TOP (max ~8mb) GROWS DOWN * leave few empty pages under stack as guard. @@ -10,7 +10,7 @@ SECTIONS .multiboot BLOCK(4K) : ALIGN(4K) { - asm/start.o(.smp) + asm/asm_start.o(.smp) asm/asm_mp.o *(.multiboot) } diff --git a/userspace/foolshell.c b/userspace/foolshell.c index 38a6e55..86c083c 100644 --- a/userspace/foolshell.c +++ b/userspace/foolshell.c @@ -66,10 +66,8 @@ int main(int argc, char **argv) if(!silent)hello(); - //char *buf=malloc(256); char *buf=calloc(sizeof(char),256); -// printf("setvbuf returned %i\n", setvbuf(stdin,NULL,_IONBF,0); while(1) @@ -80,17 +78,25 @@ int main(int argc, char **argv) while(1) { char c=fgetc(stdin); - putc(c,stdout); - if(c=='\n')break; - - buf[bl]=c; - buf[bl+1]='\0'; - bl++; + if(c=='\b') + { + if(bl==0)continue; + buf[--bl]='\0'; + putc(c,stdout); + } + else + { + putc(c,stdout); + if(c=='\n')break; + buf[bl]=c; + buf[++bl]='\0'; + } } //fgets(buf,255,stdin); //buf[strlen(buf)-1]=0; // remove \n + printf("[%s]",buf); process(buf); } |
