diff --git a/ChangeLog b/ChangeLog index 32f9d4b..57e568d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -105,5 +105,5 @@ IDT Overhaul 2019-11-08 @os-k-team * Compilation process : beginning the modernization 2019-11-11 @os-k-team - * Compilation process : "unrooting" and enhancing the compilation process scripts + * Compilation process : "unrooting" and enhancing the compilation process scripts, multi-threading * ProjectTree : better tree, without useless stuff \ No newline at end of file diff --git a/Makefile b/Makefile index f3fd8c3..c1a430f 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ .PHONY: all test test32 debug gdb install dust clean OS/K .DELETE_ON_ERROR: $(BINDIR)/kaleid - +.DEFAULT_GOAL := all ## VARIABLES ----------------------------------------------------------------- # @@ -113,16 +113,13 @@ KernSources = kernel/ke/cpuid.c kernel/mm/paging.c \ kernel/io/spkr.c kernel/po/shtdwn.c \ kernel/sh/shell.c kernel/sh/shcmds.c \ kernel/sh/musage.c kernel/io/ata.c \ - kernel/sh/argv.c + kernel/sh/argv.c kernel/ke/pit.c KernObj=$(patsubst %.c,$(KOBJDIR)/%.o,$(KernSources)) KernDep=$(patsubst %.c,$(KOBJDIR)/%.d,$(KernSources)) - -## KALEID MAKEFILE ----------------------------------------------------------- # - -all : OS/K - +all : + make OS/K -j 8 ## MISC MAKEFILE ------------------------------------------------------------- # diff --git a/ProjectTree b/ProjectTree deleted file mode 100644 index 8ed26e7..0000000 --- a/ProjectTree +++ /dev/null @@ -1,156 +0,0 @@ -#=----------------------------------------------------------------------------=# -# GNU GPL OS/K # -# # -# Desc: # -# # -# # -# Copyright © 2018-2019 The OS/K Team # -# # -# This file is part of OS/K. # -# # -# OS/K is free software: you can redistribute it and/or modify # -# it under the terms of the GNU General Public License as published by # -# the Free Software Foundation, either version 3 of the License, or # -# any later version. # -# # -# OS/K is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY# without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU General Public License for more details. # -# # -# You should have received a copy of the GNU General Public License # -# along with OS/K. If not, see . # -#=----------------------------------------------------------------------------=# - - -. -├── boot -│   ├── grub -│   │   ├── grub.cfg -│   │   └── multiboot.pdf -│   ├── loader -│   │   ├── cpu -│   │   │   ├── cpu32.inc -│   │   │   └── cpu.inc -│   │   ├── io -│   │   │   └── terminal.inc -│   │   ├── mem -│   │   │   ├── management.inc -│   │   │   └── structures.inc -│   │   ├── multiboot -│   │   │   ├── check.inc -│   │   │   └── header.inc -│   │   └── loader.asm -│   └── folder.desc -├── build -│   ├── create_disk.sh -│   ├── install-os-k.sh -│   └── kernel.ld -├── include -│   ├── ex -│   │   ├── lock.h -│   │   └── malloc.h -│   ├── init -│   │   ├── boot.h -│   │   └── mboot.h -│   ├── io -│   │   ├── ata.h -│   │   ├── cursor.h -│   │   ├── keyb.h -│   │   ├── spkr.h -│   │   └── vga.h -│   ├── ke -│   │   ├── cpuid.h -│   │   ├── idt.h -│   │   ├── proc.h -│   │   ├── sched.h -│   │   ├── spinlock.h -│   │   └── time.h -│   ├── lib -│   │   ├── buf.h -│   │   └── list.h -│   ├── mm -│   │   ├── heap.h -│   │   ├── malloc.h -│   │   └── mm.h -│   ├── po -│   │   └── shtdwn.h -│   ├── sh -│   │   ├── argv.h -│   │   └── shell.h -│   ├── asm.h -│   ├── errno.h -│   ├── kernel.h -│   ├── libc.h -│   └── vers.h -├── kaleid -│   ├── kernel -│   │   ├── init -│   │   │   ├── info.c -│   │   │   ├── init.c -│   │   │   ├── ssp.c -│   │   │   └── table.c -│   │   ├── io -│   │   │   ├── ata.asm -│   │   │   ├── ata.c -│   │   │   ├── cursor.c -│   │   │   ├── keyb.c -│   │   │   ├── spkr.c -│   │   │   └── vga.c -│   │   ├── ke -│   │   │   ├── cpuf.asm -│   │   │   ├── cpuf.inc -│   │   │   ├── cpuid.c -│   │   │   ├── idt.c -│   │   │   ├── isr.asm -│   │   │   ├── log.c -│   │   │   ├── panic.c -│   │   │   └── rtc.c -│   │   ├── mm -│   │   │   ├── gdt.asm -│   │   │   ├── gdt.c -│   │   │   ├── heap.c -│   │   │   ├── malloc.c -│   │   │   ├── map.c -│   │   │   ├── paging.asm -│   │   │   └── paging.c -│   │   ├── po -│   │   │   └── shtdwn.c -│   │   ├── ps -│   │   │   └── sched.c -│   │   └── sh -│   │   ├── argv.c -│   │   ├── musage.c -│   │   ├── shcmds.c -│   │   ├── shell.c -│   │   └── shell.h -│   ├── libbuf -│   │   ├── bclose.c -│   │   ├── bflush.c -│   │   ├── bgetc.c -│   │   ├── bmisc.c -│   │   ├── bopen.c -│   │   ├── bprint.c -│   │   ├── bputc.c -│   │   ├── bread.c -│   │   ├── bscan.c -│   │   ├── bscroll.c -│   │   └── bwrite.c -│   └── libc -│   ├── atoi.c -│   ├── ctype.c -│   ├── errno.c -│   ├── itoa.c -│   ├── mem.c -│   ├── rand.c -│   ├── sprintf.c -│   ├── string.c -│   └── strtol.c -├── AUTHORS -├── ChangeLog -├── COPYING -├── Makefile -├── ProjectTree -└── README.md - -28 directories, 100 files diff --git a/include/ke/time.h b/include/ke/time.h index 8e87ddd..0486dd6 100644 --- a/include/ke/time.h +++ b/include/ke/time.h @@ -43,6 +43,11 @@ struct Time_t uchar century; } __attribute__((packed)); +struct TimerFilo_t { + uint countDown; + ulong sema; // semaphore, don't know how it is for instance +} __attribute__((packed)); + void KeSetupRTC(void); void KeEnableRTC(void); diff --git a/include/kernel.h b/include/kernel.h index c043910..2fc17c6 100644 --- a/include/kernel.h +++ b/include/kernel.h @@ -37,6 +37,7 @@ typedef Spinlock_t Lock_t; //typedef struct Lock_t Lock_t; typedef struct Time_t Time_t; +typedef struct TimerFilo_t TimerFilo_t; typedef struct Buffer_t Buffer_t; typedef struct ListHead_t ListHead_t; typedef struct ListNode_t ListNode_t; @@ -59,7 +60,7 @@ typedef struct MemoryMap_t MemoryMap_t; typedef struct MapEntry_t MapEntry_t; typedef struct GdtEntry_t GdtEntry_t; typedef struct GdtPtr_t GdtPtr_t; -typedef struct Tss_t Tss_t; +typedef struct Tss_t Tss_t; typedef struct TssDescriptor_t TssDescriptor_t; //----------------------------------------------------------------------------// diff --git a/kaleid/kernel/ke/pit.c b/kaleid/kernel/ke/pit.c new file mode 100644 index 0000000..7b50c61 --- /dev/null +++ b/kaleid/kernel/ke/pit.c @@ -0,0 +1,67 @@ +//----------------------------------------------------------------------------// +// GNU GPL OS/K // +// // +// Desc: RTC Time related functions // +// // +// // +// Copyright © 2018-2019 The OS/K Team // +// // +// This file is part of OS/K. // +// // +// OS/K is free software: you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation, either version 3 of the License, or // +// any later version. // +// // +// OS/K is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY//without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with OS/K. If not, see . // +//----------------------------------------------------------------------------// + +#include +#include +#include + +#define COUNTDONE 1 + +static TimerFilo_t timerFilo[20]; //20 concurrent sleep max + +// +// ISR handler for the Programmable Interval Timer +// +static void HandleTimer(ISRFrame_t *regs) +{ + for (uchar i = 0; i < 20; i++) { + if (timerFilo[i].countDown > 0) { + timerFilo[i].countDown--; + + if (timerFilo[i].countDown == 0) + i; //XXX SendMessage a message to timerFifo[i].sema that COUNTDONE; + } + } +} + +static TimerFilo_t* KeFindTimerBlock(void) +{ + for(uchar i = 0; i < 20; i++) { + if (timerFilo[i].countDown == 0) + return &timerFilo[i]; + } + + return NULL; +} + +void KeSleep(uint delay) +{ + struct TimerFilo_t *timerBlock; + + if ((timerBlock = (TimerFilo_t*)KeFindTimerBlock()) == NULL) + return; + + timerBlock->countDown = delay; + // wait for a message on timerFifo[i].sema +} diff --git a/kaleid/kernel/ke/rtc.c b/kaleid/kernel/ke/rtc.c index ebfc547..b1cd20f 100644 --- a/kaleid/kernel/ke/rtc.c +++ b/kaleid/kernel/ke/rtc.c @@ -168,6 +168,9 @@ static void GetTimeFromRTC(void) CurTime.century = OriginTime.century; } +// +// ISR handler for the real time clock +// static void HandleRTC(ISRFrame_t *regs) { IoWriteByteOnPort(0x70, 0x0C); // Selects status reg C