2018-12-20 18:03:39 +01:00
|
|
|
//----------------------------------------------------------------------------//
|
|
|
|
// GNU GPL OS/K //
|
|
|
|
// //
|
2019-03-08 09:00:55 +01:00
|
|
|
// Desc: Kernel entry point //
|
2018-12-20 18:03:39 +01:00
|
|
|
// //
|
2019-02-16 23:36:33 +01:00
|
|
|
// //
|
|
|
|
// 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 <https://www.gnu.org/licenses/>. //
|
2018-12-20 18:03:39 +01:00
|
|
|
//----------------------------------------------------------------------------//
|
2019-03-18 17:25:44 +01:00
|
|
|
|
2019-04-13 09:27:36 +02:00
|
|
|
#include <extras/buf.h>
|
2019-04-21 21:18:13 +02:00
|
|
|
#include <kernel/iomisc.h>
|
|
|
|
#include <kernel/cursor.h>
|
2019-03-28 23:03:26 +01:00
|
|
|
#include <kernel/mboot.h>
|
2019-03-25 17:33:51 +01:00
|
|
|
#include <kernel/heap.h>
|
2019-03-18 17:43:41 +01:00
|
|
|
#include <kernel/mm.h>
|
2019-04-25 13:08:54 +02:00
|
|
|
#include <kernel/time.h>
|
2019-03-11 19:22:37 +01:00
|
|
|
|
2019-04-21 21:18:13 +02:00
|
|
|
// info.c
|
|
|
|
extern void BtDoSanityChecks(uint mbMagic);
|
2019-04-22 20:15:32 +02:00
|
|
|
extern void BtInitBootInfo(multiboot_info_t *mbi, void *codeSeg);
|
2019-04-01 12:02:17 +02:00
|
|
|
|
2019-04-21 21:18:13 +02:00
|
|
|
// io/vga.c
|
|
|
|
extern error_t IoInitVGABuffer(void);
|
2019-04-01 12:02:17 +02:00
|
|
|
|
2019-04-24 21:08:44 +02:00
|
|
|
//io/keyb.c
|
2019-04-24 22:40:12 +02:00
|
|
|
extern void IoEnableKeyb(void);
|
2019-04-24 21:08:44 +02:00
|
|
|
|
2019-04-24 11:40:14 +02:00
|
|
|
// cpu/idt.c
|
|
|
|
extern void IdtSetup(void);
|
|
|
|
|
2019-04-21 21:18:13 +02:00
|
|
|
// ps/proc.c test function
|
2019-03-25 17:33:51 +01:00
|
|
|
extern void pstest(void);
|
2019-03-29 14:19:29 +01:00
|
|
|
|
2019-04-24 00:05:03 +02:00
|
|
|
// interrupts tests
|
|
|
|
extern void divideByZero(void);
|
|
|
|
|
|
|
|
void test(void)
|
|
|
|
{
|
2019-04-24 21:08:44 +02:00
|
|
|
asm volatile ("hlt");
|
2019-04-24 00:05:03 +02:00
|
|
|
}
|
|
|
|
|
2018-12-25 19:09:58 +01:00
|
|
|
//
|
2019-02-16 23:36:33 +01:00
|
|
|
// Entry point of the Kaleid kernel
|
2018-12-25 19:09:58 +01:00
|
|
|
//
|
2019-04-22 20:15:32 +02:00
|
|
|
noreturn void BtStartKern(multiboot_info_t *mbInfo, uint mbMagic, void *codeSeg)
|
2018-12-29 23:51:00 +01:00
|
|
|
{
|
2019-03-24 14:44:59 +01:00
|
|
|
KeDisableIRQs();
|
2019-01-14 14:31:49 +01:00
|
|
|
|
2019-03-29 14:19:29 +01:00
|
|
|
// Initialize the BootInfo_t structure
|
2019-04-22 20:15:32 +02:00
|
|
|
BtInitBootInfo(mbInfo, codeSeg);
|
2019-03-23 23:52:18 +01:00
|
|
|
|
2019-04-04 18:47:30 +02:00
|
|
|
// Screen I/O available from this point on
|
2019-03-29 14:19:29 +01:00
|
|
|
IoInitVGABuffer();
|
2019-04-21 21:18:13 +02:00
|
|
|
IoEnableCursor();
|
|
|
|
IoUpdateCursor(0, 0);
|
|
|
|
|
2019-04-22 15:54:40 +02:00
|
|
|
KernLog("%c%c%c OS/K\n\n", 219, 219, 219); //grrr
|
2019-03-29 14:19:29 +01:00
|
|
|
|
2019-04-21 21:18:13 +02:00
|
|
|
// Sanity checks
|
|
|
|
BtDoSanityChecks(mbMagic);
|
2019-03-19 00:25:22 +01:00
|
|
|
|
2019-04-04 18:47:30 +02:00
|
|
|
// Memory & scheduler
|
2019-03-29 10:29:05 +01:00
|
|
|
MmInitMemoryMap();
|
2019-03-13 09:19:43 +01:00
|
|
|
|
2019-04-01 22:12:25 +02:00
|
|
|
// Several inits
|
2019-03-25 17:33:51 +01:00
|
|
|
MmInitHeap();
|
2019-04-01 22:12:25 +02:00
|
|
|
PsInitSched();
|
2019-04-24 21:08:44 +02:00
|
|
|
|
|
|
|
// Interrupts launching
|
2019-04-24 11:40:14 +02:00
|
|
|
IdtSetup();
|
2019-04-23 17:06:03 +02:00
|
|
|
KeEnableIRQs();
|
2019-04-24 21:08:44 +02:00
|
|
|
// Drivers enabling
|
|
|
|
IoEnableRtc();
|
2019-04-24 22:40:12 +02:00
|
|
|
IoEnableKeyb();
|
2019-04-24 21:08:44 +02:00
|
|
|
|
2019-04-25 12:23:45 +02:00
|
|
|
IoPrintRtcTime();
|
2019-04-24 22:40:12 +02:00
|
|
|
|
2019-04-26 20:11:08 +02:00
|
|
|
KernLog("There was %d ticks\n", IoGetRtcTicks());
|
2019-04-27 00:04:27 +02:00
|
|
|
for (uint i = 1; i < 2 ; i++) {
|
2019-04-26 20:11:08 +02:00
|
|
|
while (IoGetRtcTicks() < i * 10000) {
|
|
|
|
}
|
|
|
|
IoPrintRtcTime();
|
|
|
|
}
|
2019-04-24 00:05:03 +02:00
|
|
|
|
2019-04-27 00:04:27 +02:00
|
|
|
divideByZero();
|
|
|
|
|
2019-04-25 16:31:06 +02:00
|
|
|
KernLog("Goodbye after %d ticks\n", IoGetRtcTicks());
|
2019-04-04 18:47:30 +02:00
|
|
|
// End this machine's suffering
|
2019-04-13 09:27:36 +02:00
|
|
|
BFlushBuf(BStdOut);
|
2019-04-04 18:41:39 +02:00
|
|
|
KeCrashSystem();
|
2019-03-18 17:43:41 +01:00
|
|
|
}
|
2019-04-26 10:36:40 +02:00
|
|
|
|
|
|
|
void label0(void)
|
|
|
|
{
|
|
|
|
KernLog("Goodbye after %d ticks\n", IoGetRtcTicks());
|
|
|
|
// End this machine's suffering
|
|
|
|
BFlushBuf(BStdOut);
|
|
|
|
KeCrashSystem();
|
|
|
|
}
|