diff options
| author | Miguel <m.i@gmx.at> | 2018-10-17 22:52:28 +0200 |
|---|---|---|
| committer | Miguel <m.i@gmx.at> | 2018-10-17 22:52:28 +0200 |
| commit | 4d1a149531bc5d672cdf4a5a3e010662f9611d61 (patch) | |
| tree | a9bac45399bc2b09d927914c4bd34ff1338ea3b1 | |
| parent | 474c803c32fe055b4f09cb779f22b70d7eba8325 (diff) | |
starting rewriting scheduling ...v0.2
| -rw-r--r-- | Makefile | 3 | ||||
| -rw-r--r-- | grubiso/boot/grub/grub.cfg | 2 | ||||
| -rw-r--r-- | kernel/interrupts.c | 65 | ||||
| -rw-r--r-- | kernel/interrupts.h | 2 | ||||
| -rw-r--r-- | kernel/kernel.h | 2 | ||||
| -rw-r--r-- | kernel/spinlock.c | 1 | ||||
| -rw-r--r-- | userspace/files/.vimrc | 3 | ||||
| -rw-r--r-- | userspace/init.c | 112 | ||||
| -rw-r--r-- | video/compositor.c | 9 |
9 files changed, 48 insertions, 151 deletions
@@ -155,7 +155,8 @@ CLEANDIRS=$(SUBDIRS:%=clean-%) .PHONY: $(SUBDIRS) $(CLEANDIRS) $(SUBDIRS): - @echo "-- Recursing make to [$@]..."; $(MAKE) --no-print-directory -C $@ +# @echo "-- Recursing make to [$@]..."; $(MAKE) --no-print-directory -C $@ + @echo "-- Recursing make to [$@]..."; $(MAKE) -C $@ @echo "-- Returned from [$@]" $(CLEANDIRS): diff --git a/grubiso/boot/grub/grub.cfg b/grubiso/boot/grub/grub.cfg index 5c27c9e..86a5f1d 100644 --- a/grubiso/boot/grub/grub.cfg +++ b/grubiso/boot/grub/grub.cfg @@ -1,4 +1,4 @@ -set timeout=1 //seconds +set timeout=0 //seconds set default=4 if loadfont ${prefix}/fonts/unicode.pf2 diff --git a/kernel/interrupts.c b/kernel/interrupts.c index 61a03e2..b7cdd74 100644 --- a/kernel/interrupts.c +++ b/kernel/interrupts.c @@ -50,7 +50,9 @@ static void int_install_ir(int irq, uint16_t flags, uint16_t sel, void *addr) idt[irq].sel=sel; } -/** register an interrupt handler for given irq number */ +/** + * Register an interrupt handler for given irq number. + */ void interrupt_register(uint32_t irq, uint32_t func_addr) { if(irq<128||irq>160)kpanic("irq number out of range!"); @@ -65,14 +67,12 @@ void interrupt_register(uint32_t irq, uint32_t func_addr) uint32_t interrupt_handler(uint32_t esp, uint32_t irq) { uint32_t cpu=smp_get(SMP_APIC_ID); - - if(handlers[irq]!=0) + + if(handlers[irq]!=0)// kb,mouse,e1000,pit,... { uint32_t (*f)(uint32_t esp)=handlers[irq]; esp=f(esp); - scheduler_wake_worker(esp); - apic_eoi(); - esp=scheduler_run(esp,-1); + apic_eoi(); return esp; } @@ -93,8 +93,9 @@ uint32_t interrupt_handler(uint32_t esp, uint32_t irq) return esp; } - if(irq==INTERRUPT_SYSCALL) // do not EOI + if(irq==INTERRUPT_SYSCALL) { + apic_eoi(); uint32_t *stack; stack=esp; task_syscall(stack[11],stack[8],stack[10],stack[9]); //eax,ebx,ecx,edx @@ -104,56 +105,6 @@ uint32_t interrupt_handler(uint32_t esp, uint32_t irq) } kpanic("unhandled interrupt %d",irq); - - /* - if(handlers[irq]!=0) - { - //uint32_t (*f)(uint32_t esp)=handlers[irq]; - //esp=f(esp); - apic_eoi(); - } - - else if(irq!=INTERRUPT_SYSCALL&&irq!=INTERRUPT_IPI&&irq!=INTERRUPT_APIC_TIMER) - { - kpanic("unhandled interrupt %d",irq); - } - - // process IRQ - switch(irq) - { - case INTERRUPT_SYSCALL: - stack=esp; - // task_syscall(stack[11],stack[8],stack[10],stack[9]); //eax,ebx,ecx,edx - break; - - - case INTERRUPT_APIC_TIMER: // frequency is configured in smp.c (100hz) - esp=scheduler_run(esp,-1); - apic_eoi(); - break; - - case INTERRUPT_IPI: // inter process interrupt - esp=scheduler_run(esp,-1); - apic_eoi(); - break; - - case 255: // default or spurious - kpanic("Spurious/Unknown Interrupt!?"); - break; - } - - // reschedule to kernel worker on these - if(irq==INTERRUPT_SYSCALL||irq==INTERRUPT_KEYBOARD||irq==INTERRUPT_MOUSE) - { - // scheduler_wake_worker(esp); - esp=scheduler_run(esp,-1); - } - - // Ack all to LAPIC, except software syscalls - - return esp; - - */ } /** diff --git a/kernel/interrupts.h b/kernel/interrupts.h index 31b0cc0..91bc2f6 100644 --- a/kernel/interrupts.h +++ b/kernel/interrupts.h @@ -56,6 +56,8 @@ void interrupts_init(); void interrupts_install(); + +/** Register an interrupt handler for given irq number */ void interrupt_register(uint32_t irq, uint32_t func_addr); #endif diff --git a/kernel/kernel.h b/kernel/kernel.h index 2393719..9e8d5e5 100644 --- a/kernel/kernel.h +++ b/kernel/kernel.h @@ -25,7 +25,7 @@ REFERENCES #define VESA_MAX_WIDTH 1920 #define VESA_MAX_HEIGHT 1080 -#define DISABLE_E1000 +//#define DISABLE_E1000 //#define FOOLOS_UNIT_TESTING // Run Unit Tests //#define FOOLOS_LOG_OFF // Turn off logging (disables serial port alltogether) //#define FOOLOS_COLORLESS // Turn off colors in log diff --git a/kernel/spinlock.c b/kernel/spinlock.c index b7ff6b7..2a713ba 100644 --- a/kernel/spinlock.c +++ b/kernel/spinlock.c @@ -16,4 +16,3 @@ void spinlock_release(uint32_t i) uint32_t *addr=spinlocks+i; asm("movb $0,%0"::"m"(*addr)); } - diff --git a/userspace/files/.vimrc b/userspace/files/.vimrc index a9d6328..80484ed 100644 --- a/userspace/files/.vimrc +++ b/userspace/files/.vimrc @@ -11,3 +11,6 @@ set ft=c set t_me=[37;40m " todo t_ve " todo t_vi + + +set bs=eol diff --git a/userspace/init.c b/userspace/init.c index e1ab531..dc21678 100644 --- a/userspace/init.c +++ b/userspace/init.c @@ -1,98 +1,38 @@ -//char *argv1[]={"xterm","/bin/foolstart",0}; -char *argv1[]={"xterm","/bin/fsh",0}; -//char *argv1[]={"xterm","/bin/vim",0}; -//char *argv1[]={"xterm","/bin/nc",0}; +/** xinit + * + * TODO: console version + * + * */ + char *env1[]={"HOME=/home/miguel","PS1=\033[34m$\033[37m","PWD=/home/miguel","PATH=/bin","TERM=fool-term",0}; -int main(int argc, char **argv) -{ - execve("/bin/xterm",argv1,env1); - /* +#define LAUNCH_COUNT 3 - int pid=fork(); +char *argv1[][4]={ + {"/bin/xterm","xterm","/bin/fsh",0}, + {"/bin/xterm","xterm","/bin/fsh",0}, + {"/bin/xterm","xterm","/bin/fsh",0}, +}; - if(!pid) - { - execve("/bin/xterm",argv1,env1); - } - else - { - while(1) - { - _gui_win(); - vesa_init(0); - void *tty=terminal_init_vesa(); - getchar(); - terminal_put('X'); - } +void fork_and_exec(char **argv) +{ + int pid=fork(); - } - */ + if(!pid) //child + { + execve(argv[0],&argv[1],env1); + while(1);//hopefully never reached + } } - /* - int pid=_fork(); - - if(pid==0) - { - _execve("/bin/xterm",NULL,NULL); - int pid=_fork(); - - if(pid==0) - { - _execve("/bin/xterm",NULL,NULL); - } - else - { - _execve("/bin/xterm",NULL,NULL); - } - } - else - { - _execve("/bin/xterm",NULL,NULL); - while(1); // block - - int pid=_fork(); - if(pid==0) - { - _execve("/bin/pain2",NULL,NULL); - } - else - { - _execve("/bin/pain1",NULL,NULL); - //_execve("/bin/pain3",NULL,NULL); - } - } - - - return 0; - // - -// char *argv1[]={"/bin/fsh",0}; - // char *env1[]={"HOME=/home/miguel","PS1=\033[34m$\033[37m","PWD=/home/miguel","PATH=/bin","TERM=fool-term",0}; - +int main(int argc, char **argv) +{ - // loop forever and spawn shells if the top-shell exits - while(1) + for(int i=0;i<LAUNCH_COUNT;i++) { + fork_and_exec(argv1[i]); + } - int pid=_fork(); - - if(pid==0) - { - printf("fool-init: spawning fool-shell\n"); - _execve("/bin/fsh",argv1,env1); // replace process with our foolshell :) - while(1) puts("FATAL ERROR: Something terrible happened. Unable to Execute SHELL!\n"); - } - - // wait until our child process state changes (exits) - // and respawn SHELL - _wait(pid); - - printf("fool-init: respawning new fool-shell\n"); - - } + wait(999);/// TODO: here we should wait for commnads to spawn new processes? - return 0; } - */ diff --git a/video/compositor.c b/video/compositor.c index 5826c03..e7566f2 100644 --- a/video/compositor.c +++ b/video/compositor.c @@ -406,7 +406,7 @@ void compositor_add_window(uint32_t addr,uint32_t pid,ringbuffer *r) windows[0].draw_meat=true; next_window++; - compositor_mouse_handle(200,200,0); + compositor_mouse_handle(0,0,0); } // TODO : TEXTMODE FALLBACK! @@ -433,6 +433,8 @@ void compositor_init(uint16_t width, uint16_t height, uint16_t depth, uint16_t p add_icon("vim"); add_icon("vim"); add_icon("vim"); + + compositor_mouse_handle(200,200,0); } void compositor_wake() @@ -465,8 +467,6 @@ void compositor_swap_buffers() frames=0; } - - static bool first=true; if(first)memcpy(VMEM_FRAMEBUFFER,bgimage,vesa_pitch*vesa_height);// TODO optimize? rects only too?? first=false; @@ -592,7 +592,7 @@ void compositor_mouse_handle(int16_t diff_x,int16_t diff_y, uint8_t key) if(w->posx<0)w->posx=0; if(w->posy<0)w->posy=0; if(w->posx+w->width>=vesa_width)w->posx=vesa_width-640; - if(w->posy+w->height>=vesa_height)w->posy=vesa_height-480; + if(w->posy+w->height>=vesa_height)w->posy=vesa_height-400; w->draw_border=true; @@ -602,6 +602,7 @@ void compositor_mouse_handle(int16_t diff_x,int16_t diff_y, uint8_t key) w->draw_meat=true; if(lastkey&1) { + w->draw_border=true; uint32_t xy=(0<<16)|(0); uint32_t wh=(640<<16)|(400); |
