From c157e6535211e8baaa00f9cca3ed445f8dae386b Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Tue, 6 Sep 2011 19:51:47 +0200 Subject: [PATCH] Removed lots of deprecated suff! --- libmaxsi/hsrc/io.h | 6 - libmaxsi/memory.cpp | 2 - sortix/Makefile | 27 +++- sortix/application.cpp | 63 --------- sortix/astroids.cpp | 143 ------------------- sortix/astroids.h | 64 --------- sortix/conway.cpp | 194 ------------------------- sortix/conway.h | 41 ------ sortix/globals.h | 32 ----- sortix/http.cpp | 183 ------------------------ sortix/iprintable.cpp | 257 ---------------------------------- sortix/iprintable.h | 48 ------- sortix/isr.cpp | 2 - sortix/kernel.cpp | 4 - sortix/keyboard.cpp | 9 -- sortix/link.ld | 33 ----- sortix/log.cpp | 178 ----------------------- sortix/log.h | 30 ---- sortix/pci.cpp | 4 - sortix/pong.cpp | 311 ----------------------------------------- sortix/pong.h | 45 ------ sortix/scheduler.cpp | 2 - sortix/shell.cpp | 167 ---------------------- sortix/shell.h | 62 -------- sortix/syscall.cpp | 2 - sortix/test.cpp | 12 -- sortix/time.cpp | 3 - sortix/types.h | 101 ------------- 28 files changed, 25 insertions(+), 2000 deletions(-) delete mode 100644 sortix/application.cpp delete mode 100644 sortix/astroids.cpp delete mode 100644 sortix/astroids.h delete mode 100644 sortix/conway.cpp delete mode 100644 sortix/conway.h delete mode 100644 sortix/globals.h delete mode 100644 sortix/http.cpp delete mode 100644 sortix/iprintable.cpp delete mode 100644 sortix/iprintable.h delete mode 100644 sortix/link.ld delete mode 100644 sortix/pong.cpp delete mode 100644 sortix/pong.h delete mode 100644 sortix/shell.cpp delete mode 100644 sortix/shell.h delete mode 100644 sortix/test.cpp delete mode 100644 sortix/types.h diff --git a/libmaxsi/hsrc/io.h b/libmaxsi/hsrc/io.h index 3fc07aff..9193e7bc 100644 --- a/libmaxsi/hsrc/io.h +++ b/libmaxsi/hsrc/io.h @@ -44,12 +44,6 @@ namespace Maxsi size_t WriteAt(int FileDesc, const void* Buffer, size_t BufferSize, intmax_t Position); } - // TODO: This namespace is hereby deprecated as it was stupid. Delete it soon. - namespace StdOut - { - size_t Print(const char* Message); - } - size_t Print(const char* msg); size_t PrintF(const char* format, ...); } diff --git a/libmaxsi/memory.cpp b/libmaxsi/memory.cpp index 8e16cbde..dc858173 100644 --- a/libmaxsi/memory.cpp +++ b/libmaxsi/memory.cpp @@ -30,8 +30,6 @@ #ifdef SORTIX_KERNEL #include -#include // DEBUG -#include // DEBUG #include // DEBUG #include diff --git a/sortix/Makefile b/sortix/Makefile index 77a23bea..cdc371ad 100644 --- a/sortix/Makefile +++ b/sortix/Makefile @@ -31,7 +31,7 @@ ifdef X86FAMILY CPUFLAGS:=$(CPUFLAGS) -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow endif -DIRS=. x64 x86 +DIRS=. x64 x86 x86-family DEFINES:=-DSORTIX_KERNEL $(CPUDEFINES) DEFINES:=$(DEFINES) -DPLATFORM_VIRTUAL_MEMORY @@ -44,7 +44,30 @@ DEFINES:=$(DEFINES) -DINITRD CPPFLAGSRELEASE=-s -O3 CPPFLAGSDEBUG= CPPFLAGS=-I.. -I. $(CPUDEFINES) $(CPUFLAGS) -std=gnu++0x -Wall -Wextra -nostdlib -fno-builtin -nostartfiles -nodefaultlibs -fno-exceptions -fno-rtti -fno-stack-protector $(DEFINES) $(CPPFLAGSRELEASE) -OBJS=$(CPUOBJS) kernel.o descriptor_tables.o isr.o time.o log.o iprintable.o panic.o keyboard.o memorymanagement.o scheduler.o syscall.o application.o pong.o sound.o pci.o uart.o conway.o test.o http.o vgaterminal.o serialterminal.o descriptors.o device.o vga.o elf.o process.o initrd.o ../libmaxsi/libmaxsi-sortix.a +OBJS=$(CPUOBJS) \ +kernel.o \ +descriptor_tables.o \ +isr.o \ +time.o \ +log.o \ +panic.o \ +keyboard.o \ +memorymanagement.o \ +scheduler.o \ +syscall.o \ +sound.o \ +pci.o \ +uart.o \ +vgaterminal.o \ +serialterminal.o \ +descriptors.o \ +device.o \ +vga.o \ +elf.o \ +process.o \ +initrd.o \ +../libmaxsi/libmaxsi-sortix.a + JSOBJS:=$(subst .o,-js.o,$(OBJS)) all: sortix.bin diff --git a/sortix/application.cpp b/sortix/application.cpp deleted file mode 100644 index 8bb890c0..00000000 --- a/sortix/application.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/****************************************************************************** - - COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011. - - This file is part of Sortix. - - Sortix 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 (at your option) any later - version. - - Sortix 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 Sortix. If not, see . - - application.cpp - A test application for the scheduler and libmaxsi. - -******************************************************************************/ - -#include -#include -#include - -using namespace Maxsi; - -void* TestThread(void* Parameter) -{ - for ( size_t I = 0; I < 64; I++ ) - { - StdOut::Print("."); - Thread::USleep(20*1000); // Sleep 100 * 1000 microseconds = 100 ms. - } - - StdOut::Print("\n"); - - return NULL; -} - -// The entry point in this sample program for sortix. -void* RunApplication(void* Parameter) -{ - StdOut::Print("Hello, says the thread!\n"); - - const char* Message = "Oooh! And message passing works!\n"; - - while ( true ) - { - StdOut::Print("Created Thread: "); - if ( Thread::Create(TestThread, Message) == 0 ) - { - StdOut::Print("ERROR: Could not create child thread\n"); - } - Thread::USleep(1300 * 1000); // Sleep 2 seconds. - } - - return NULL; -} - diff --git a/sortix/astroids.cpp b/sortix/astroids.cpp deleted file mode 100644 index 9d2fd857..00000000 --- a/sortix/astroids.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/****************************************************************************** - - COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011. - - This file is part of Sortix. - - Sortix 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 (at your option) any later - version. - - Sortix 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 Sortix. If not, see . - - astroids.cpp - IN SPACE, NO ONE CAN HEAR YOU find ~ | xargs shred - -******************************************************************************/ - -#include "platform.h" -#include -#include "globals.h" -#include "iirqhandler.h" -#include "iprintable.h" -#include "keyboard.h" -#include "timer.h" -#include "log.h" -#include "astroids.h" - -using namespace Maxsi; - -namespace Sortix -{ - DEFINE_GLOBAL_OBJECT(Astroids, Astroids); - - const int Height = 25; - const int Width = 80; - - void Astroids::Init() - { - Time = 0; - - Reset(); - Update(); - - GKeyboard->SetReader(this); - GTimer->SetTimerable(this); - } - - void Astroids::ClearScreen() - { - uint16_t* Destination = (uint16_t*) 0xB8000; - - // Copy and apply colors. - for ( int Y = 0; Y < Height; Y++ ) - { - uint16_t Color = COLOR8_BLACK << 8; - - for ( int X = 0; X < Width; X++ ) - { - Destination[X + Y*Width] = ' ' | Color; - } - } - } - - void Astroids::Reset() - { - ClearScreen(); - PX = Width/2; - PY = Height/2; - PVX = 0; - PVY = 0; - TrailX = PX; - TrailY = PY; - TrailLen = 0; - TrailMaxLen = 15; - } - - void Astroids::Update() - { - uint16_t* Destination = (uint16_t*) 0xB8000; - - PX += PVX; PX = ((nat) PX) % ((nat) Width); - PY += PVY; PY = ((nat) PY) % ((nat) Height); - - uint16_t Prev = 0; - if ( !(PVX == 0 && PVY == 0) && Destination[PX + PY*Width] > 0 ) { Reset(); } - - if ( !(PVX == 0 && PVY == 0) ) - { - if ( PVX < 0 ) { Prev = 0; } - if ( PVX > 0 ) { Prev = 1; } - if ( PVY < 0 ) { Prev = 2; } - if ( PVY > 0 ) { Prev = 3; } - - if ( TrailMaxLen <= TrailLen ) - { - uint16_t AtTrail = Destination[TrailX + TrailY*Width]; - Destination[TrailX + TrailY*Width] = ' ' | (COLOR8_BLACK << 8); - if ( (AtTrail & 0x4) == 0 ) { TrailX--; } else - if ( (AtTrail & 0x4) == 1 ) { TrailX++; } else - if ( (AtTrail & 0x4) == 2 ) { TrailY--; } else - if ( (AtTrail & 0x4) == 3 ) { TrailY++; } - } - else { TrailLen++; } - } - Destination[PX + PY*Width] = (COLOR8_GREEN << 12) | Prev; - - NextUpdate = Time + 75; - } - - void Astroids::OnKeystroke(uint32_t CodePoint, bool KeyUp) - { - const uint32_t UP = 0xFFFFFFFF - 20; - const uint32_t LEFT = 0xFFFFFFFF - 21; - const uint32_t RIGHT = 0xFFFFFFFF - 22; - const uint32_t DOWN = 0xFFFFFFFF - 23; - - if ( CodePoint == '\n' && !KeyUp ) - { - ClearScreen(); - Reset(); - Update(); - } - - if ( !(PVX == 0 && PVY == 1) && (CodePoint == 'w' || CodePoint == 'W') && !KeyUp ) { PVY = -1; PVX = 0; } - if ( !(PVX == 1 && PVY == 0) && (CodePoint == 'a' || CodePoint == 'A') && !KeyUp ) { PVY = 0; PVX = -1; } - if ( !(PVX == 0 && PVY == -1) && (CodePoint == 's' || CodePoint == 'S') && !KeyUp ) { PVY = 1; PVX = 0; } - if ( !(PVX == -1 && PVY == 0) && (CodePoint == 'd' || CodePoint == 'D') && !KeyUp ) { PVY = 0; PVX = 1; } - } - - void Astroids::OnFuture(uint32_t Miliseconds) - { - Time += Miliseconds; - - if ( NextUpdate <= Time ) { Update(); } - } -} diff --git a/sortix/astroids.h b/sortix/astroids.h deleted file mode 100644 index cae8167a..00000000 --- a/sortix/astroids.h +++ /dev/null @@ -1,64 +0,0 @@ -/****************************************************************************** - - COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011. - - This file is part of Sortix. - - Sortix 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 (at your option) any later - version. - - Sortix 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 Sortix. If not, see . - - astroids.h - IN SPACE, NO ONE CAN HEAR YOU find ~ | xargs shred - -******************************************************************************/ - -#ifndef SORTIX_ASTROIDS_H -#define SORTIX_ASTROIDS_H - -namespace Sortix -{ - class Astroids : public IKeystrokable, public ITimerable - { - private: - nat Time; - nat NextUpdate; - - private: - int PX; - int PY; - int TrailX; - int TrailY; - int TrailLen; - int TrailMaxLen; - int PVX; - int PVY; - - public: - void Init(); - - private: - void ClearScreen(); - void Reset(); - void Update(); - - public: - virtual void OnKeystroke(uint32_t CodePoint, bool KeyUp); - virtual void OnFuture(uint32_t Miliseconds); - - }; - - DECLARE_GLOBAL_OBJECT(Astroids, Astroids); -} - -#endif - diff --git a/sortix/conway.cpp b/sortix/conway.cpp deleted file mode 100644 index bdded776..00000000 --- a/sortix/conway.cpp +++ /dev/null @@ -1,194 +0,0 @@ -/****************************************************************************** - - COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011. - - This file is part of Sortix. - - Sortix 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 (at your option) any later - version. - - Sortix 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 Sortix. If not, see . - - conway.cpp - THE GAME! You lost it. OF LIFE! - -******************************************************************************/ - -#include "platform.h" - -#include "globals.h" -#include "iprintable.h" -#include "log.h" -#include "vga.h" - -#ifdef PLATFORM_SERIAL -#include "uart.h" -#endif - -namespace Sortix -{ - namespace Conway - { - const int Height = 25; - const int Width = 80; - const int RowStride = Width + 2; - const int BufferSize = (Height+2) * (Width+2); - -#ifdef PLATFORM_SERIAL - VGA::Frame FrameData; - VGA::Frame* Frame = &FrameData; -#else - VGA::Frame* Frame = (VGA::Frame*) 0xB8000; -#endif - - char FrameA[BufferSize]; - char FrameB[BufferSize]; - char* CurrentFrame; - char* LastFrame; - bool Running; - int PosX; - int PosY; - int TimeToNextFrame; - int Time; - - void Clear() - { - for ( int I = 0; I < BufferSize; I++ ) { FrameA[I] = 0; FrameB[I] = 0; } - } - - void Init() - { - CurrentFrame = FrameA; - LastFrame = FrameB; - - Running = false; - - PosY = Height / 2 + 1; - PosX = Width / 2 + 1; - Time = 0; - - Clear(); - } - - void Cycle() - { - for ( int Y = 1; Y <= Height; Y++ ) - { - for ( int X = 1; X <= Width; X++ ) - { - int AliveAround = 0; - int Current = LastFrame[Y * RowStride + X]; - - if ( LastFrame[(Y-1) * RowStride + (X-1)] > 0 ) { AliveAround++; } - if ( LastFrame[(Y-1) * RowStride + (X-0)] > 0 ) { AliveAround++; } - if ( LastFrame[(Y-1) * RowStride + (X+1)] > 0 ) { AliveAround++; } - if ( LastFrame[(Y-0) * RowStride + (X-1)] > 0 ) { AliveAround++; } - if ( LastFrame[(Y-0) * RowStride + (X+1)] > 0 ) { AliveAround++; } - if ( LastFrame[(Y+1) * RowStride + (X-1)] > 0 ) { AliveAround++; } - if ( LastFrame[(Y+1) * RowStride + (X-0)] > 0 ) { AliveAround++; } - if ( LastFrame[(Y+1) * RowStride + (X+1)] > 0 ) { AliveAround++; } - - CurrentFrame[Y * RowStride + X] = ( (Current > 0 && (AliveAround == 3 || AliveAround == 2)) || (Current == 0 && AliveAround == 3) ) ? 1 : 0; - } - } - - // Swap buffers. - char* TMP = LastFrame; LastFrame = CurrentFrame; CurrentFrame = TMP; - } - - void Render() - { - uint16_t* Destination = Frame->Data; - - uint16_t Set = 'O' | (COLOR8_LIGHT_GREY << 8); - uint16_t Unset = ' ' | (COLOR8_LIGHT_GREY << 8); - - for ( int Y = 1; Y <= Height; Y++ ) - { - for ( int X = 1; X <= Width; X++ ) - { - Destination[(Y-1) * Width + (X-1)] = (LastFrame[Y * RowStride + X] > 0) ? Set : Unset; - } - } - - // Render the cursor. - if ( !Running ) - { - Destination[(PosY-1) * Width + (PosX-1)] |= (COLOR8_RED << 12); - } - -#ifdef PLATFORM_SERIAL - UART::RenderVGA(Frame); -#endif - } - - void Update(int TimePassed) - { -#ifdef PLATFORM_SERIAL - while ( true ) - { - int C = UART::TryPopChar(); - - if ( C == 'r' || C == 'R' ) { TimeToNextFrame = 0; Running = !Running; } - - if ( !Running ) - { - if ( C == 'w' || C == 'W' ) { if ( PosY > 1 ) { PosY--; } } - if ( C == 's' || C == 'S' ) { if ( PosY < Height ) { PosY++; } } - if ( C == 'a' || C == 'A' ) { if ( PosX > 1 ) { PosX--; } } - if ( C == 'd' || C == 'D' ) { if ( PosX < Width ) { PosX++; } } - if ( C == 'c' || C == 'C' ) { Clear(); } - if ( C == ' ' ) { LastFrame[PosY * RowStride + PosX] = 1 - LastFrame[PosY * RowStride + PosX]; } - } - - if ( C == -1 ) { break; } - } -#endif - - if ( Running ) - { - if ( TimeToNextFrame <= TimePassed ) - { - Cycle(); - TimeToNextFrame = 50; - } - else - { - TimeToNextFrame -= TimePassed; - } - } - - Render(); - } - - void OnFuture() - { - const int TimePassed = 10; - - Time += TimePassed; - - -#ifdef PLATFORM_SERIAL - -#ifdef JSSORIX - const nat WaitTime = 2000; -#else - const nat WaitTime = 3500; -#endif - - // Artificially display the boot welcome screen. - if ( Time < WaitTime ) { return; } -#endif - - Update(TimePassed); - } - } -} diff --git a/sortix/conway.h b/sortix/conway.h deleted file mode 100644 index 46913b1e..00000000 --- a/sortix/conway.h +++ /dev/null @@ -1,41 +0,0 @@ -/****************************************************************************** - - COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011. - - This file is part of Sortix. - - Sortix 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 (at your option) any later - version. - - Sortix 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 Sortix. If not, see . - - conway.h - THE GAME! You lost it. OF LIFE! - -******************************************************************************/ - -#ifndef SORTIX_CONWAY_H -#define SORTIX_CONWAY_H - -namespace Sortix -{ - namespace Conway - { - void Init(); - void Cycle(); - void Render(); - void Update(int TimePassed); - void OnFuture(); - } -} - -#endif - diff --git a/sortix/globals.h b/sortix/globals.h deleted file mode 100644 index 4e961cf3..00000000 --- a/sortix/globals.h +++ /dev/null @@ -1,32 +0,0 @@ -/****************************************************************************** - - COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011. - - This file is part of Sortix. - - Sortix 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 (at your option) any later - version. - - Sortix 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 Sortix. If not, see . - - globals.h - Macros useful to declare and define global objects in Sortix. - -******************************************************************************/ - -#ifndef SORTIX_GLOBALS_H -#define SORTIX_GLOBALS_H - -#define DECLARE_GLOBAL_OBJECT(Type, Name) extern Type* G##Name; -#define DEFINE_GLOBAL_OBJECT(Type, Name) Type D##Name; Type* G##Name = &D##Name; - -#endif - diff --git a/sortix/http.cpp b/sortix/http.cpp deleted file mode 100644 index b5a96a9b..00000000 --- a/sortix/http.cpp +++ /dev/null @@ -1,183 +0,0 @@ -/****************************************************************************** - - COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011. - - This file is part of Sortix. - - Sortix 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 (at your option) any later - version. - - Sortix 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 Sortix. If not, see . - - http.cpp - A very small http server running in kernel mode, heh! - -******************************************************************************/ - -#include "platform.h" -#include -#include -#include "uart.h" - -using namespace Maxsi; - -namespace Sortix -{ - namespace HTTP - { - uint32_t Left; - - bool TryByte(char* Dest) - { - if ( Left == 0 ) - { - UART::Read((uint8_t*) &Left, sizeof(Left)); - } - - if ( Left == 0 ) { return false; } - - UART::Read((uint8_t*) Dest, 1); - Left--; - - return true; - } - - void Close() - { - uint32_t ToSend = 0; - UART::Write(&ToSend, sizeof(ToSend)); - } - - void Send(const char* Response, uint32_t Len) - { - UART::Write(&Len, sizeof(Len)); - UART::Write(Response, Len); - } - - void Respond(const char* Body, uint32_t Len) - { - const char* Headers = "HTTP/1.1 200 Success\r\nConnection: close\r\nContent-Type: application/xhtml+xml\r\n\r\n"; - Send(Headers, String::Length(Headers)); - Send(Body, Len); - Close(); - } - - void HandleResource(const char* Operation, const char* Resource) - { - if ( String::Compare(Resource, "/") == 0 ) - { - const char* Response = - "\n" - "\n" - " \n" - " Hello, World!\n" - " \n" - " \n" - "

\"Hello, World!\" said Sortix with a big smile!

\n" - "

\"Finally\", Sortix continued, \"someone completed a working HTTP server that runs under Sortix, which runs as a virtual machine, that communicates over a serial terminal driver to proxy server that communicates with the real internet!\".

\n" - "

Sortix was happy.

\n" - "

This website was served by a server running under my very own operating system, which is connected to the internet through a serial modem driver. Heh!

\n" - " \n" - "\n" - ; - - Respond(Response, String::Length(Response)); return; - } - else - { - const char* Response = "HTTP/1.1 400 Not Found\r\nConnection: close\r\n\r\nHTTP 404 File Not Found\n"; - Send(Response, String::Length(Response)); Close(); return; - } - } - - void HandleConnection() - { - char Buffer[1024]; - - char* Operation = NULL; - char* Resource = NULL; - - size_t Used = 0; - - nat State = 0; - - while ( true ) - { - if ( !TryByte(Buffer + Used) ) { return; } - Used++; - Buffer[Used] = '\0'; - - if ( State == 0 ) - { - if ( Used >= 4 ) - { - if ( Buffer[0] == 'G' && Buffer[1] == 'E' && Buffer[2] == 'T' && Buffer[3] == ' ' ) - { - State++; - Buffer[3] = '\0'; - Operation = Buffer; - } - else - { - const char* Response = "HTTP/1.1 501 Not Implemented\r\nConnection: close\r\n\r\nThis request is not supported by this server!\n"; - Send(Response, String::Length(Response)); Close(); return; - } - } - } - if ( State == 1 ) - { - if ( Buffer[Used-1] == ' ' ) - { - Resource = Buffer + 4; - Buffer[Used-1] = '\0'; - State++; - break; - } - } - - if ( Used == 1024 ) - { - const char* Response = "HTTP/1.1 400 Bad Request\r\n\r\n"; - Send(Response, String::Length(Response)); Close(); return; - } - } - - nat LineChars = 0; - - while ( LineChars < 4 ) - { - char TMP; - if ( !TryByte(&TMP) ) { return; } - - if ( TMP == '\r' || TMP == '\n' ) - { - LineChars++; - } - else - { - LineChars = 0; - } - } - - HandleResource(Operation, Resource); - } - - void Init() - { - Left = 0; - - while ( true ) - { - HandleConnection(); - } - } - } -} diff --git a/sortix/iprintable.cpp b/sortix/iprintable.cpp deleted file mode 100644 index adbce5eb..00000000 --- a/sortix/iprintable.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/****************************************************************************** - - COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011. - - This file is part of Sortix. - - Sortix 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 (at your option) any later - version. - - Sortix 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 Sortix. If not, see . - - iprintable.cpp - A common interface shared by all devices that can be printed text to. - -******************************************************************************/ - -#include "platform.h" -#include "iprintable.h" - -namespace Sortix -{ - int UInt8ToString(uint8_t Num, char* Dest) - { - uint8_t Copy = Num; - int Result = 0; - - while ( Copy > 9 ) { Copy /= 10; Result++; } - - int Offset = Result; - while ( Offset >= 0 ) - { - Dest[Offset] = '0' + Num % 10; Num /= 10; Offset--; - } - - return Result + 1; - } - - int UInt16ToString(uint16_t Num, char* Dest) - { - uint16_t Copy = Num; - int Result = 0; - - while ( Copy > 9 ) { Copy /= 10; Result++; } - - int Offset = Result; - while ( Offset >= 0 ) - { - Dest[Offset] = '0' + Num % 10; Num /= 10; Offset--; - } - - return Result + 1; - } - - int UInt32ToString(uint32_t Num, char* Dest) - { - uint32_t Copy = Num; - int Result = 0; - - while ( Copy > 9 ) { Copy /= 10; Result++; } - - int Offset = Result; - while ( Offset >= 0 ) - { - Dest[Offset] = '0' + Num % 10; Num /= 10; Offset--; - } - - return Result + 1; - } - - int UInt64ToString(uint64_t Num, char* Dest) - { - uint64_t Copy = Num; - int Result = 0; - - while ( Copy > 9 ) { Copy /= 10; Result++; } - - int Offset = Result; - while ( Offset >= 0 ) - { - Dest[Offset] = '0' + Num % 10; Num /= 10; Offset--; - } - - return Result + 1; - } - - // Missing functions here. - - int UInt32ToString16(uint32_t Num, char* Dest) - { - uint32_t Copy = Num; - int Result = 0; - - while ( Copy > 15 ) { Copy /= 16; Result++; } - - int Offset = Result; - while ( Offset >= 0 ) - { - if ( Num % 16 < 10 ) - { - Dest[Offset] = '0' + Num % 16; - } - else - { - Dest[Offset] = 'A' + (Num % 16) - 10; - } - Num /= 16; Offset--; - } - - return Result + 1; - } - - int UInt64ToString16(uint64_t Num, char* Dest) - { - uint64_t Copy = Num; - int Result = 0; - - while ( Copy > 15 ) { Copy /= 16; Result++; } - - int Offset = Result; - while ( Offset >= 0 ) - { - if ( Num % 16 < 10 ) - { - Dest[Offset] = '0' + Num % 16; - } - else - { - Dest[Offset] = 'A' + (Num % 16) - 10; - } - Num /= 16; Offset--; - } - - return Result + 1; - } - - // Missing functions here. - - #define READY_SIZE 128 - #define READY_FLUSH() Ready[AmountReady] = 0; Written += Print(Ready); AmountReady = 0; - #define F(N) (*(Format+N)) - - #define U32 1 - #define U64 2 - #define X32 3 - #define X64 4 - #define STRING 5 - #define CHAR 6 - - - size_t IPrintable::PrintF(const char* Format, ...) - { - va_list list; - va_start(list, Format); - size_t result = PrintFV(Format, list); - va_end(list); - return result; - } - - size_t IPrintable::PrintFV(const char* Format, va_list Parameters) - { - size_t Written = 0; - char Ready[READY_SIZE + 1]; - int AmountReady = 0; - - while ( *Format != '\0' ) - { - if ( *Format != '%' ) - { - Ready[AmountReady] = *Format; AmountReady++; Format++; - } - else - { - int Type = 0; - int Len = 1; - - if ( F(1) == 'c' ) { Type = CHAR; Len += 1; } else - if ( F(1) == 's' ) { Type = STRING; Len += 1; } else - if ( F(1) == 'u' ) { Type = U32; Len += 1; } else - if ( F(1) == '3' && F(2) == '2' && F(3) == 'u' ) { Type = U32; Len += 3; } else - if ( F(1) == '6' && F(2) == '4' && F(3) == 'u' ) { Type = U64; Len += 3; } else - if ( F(1) == 'x' ) { Type = X32; Len += 1; } else - if ( F(1) == '3' && F(2) == '2' && F(3) == 'x' ) { Type = X32; Len += 3; } else - if ( F(1) == '6' && F(2) == '4' && F(3) == 'x' ) { Type = X64; Len += 3; } else - #ifdef PLATFORM_X86 - if ( F(1) == 'z' ) { Type = U32; Len += 1; } else - if ( F(1) == 'p' ) { Type = X32; Len += 1; } else - #elif defined(PLATFORM_X64) - if ( F(1) == 'z' ) { Type = U64; Len += 1; } else - if ( F(1) == 'p' ) { Type = X64; Len += 1; } else - #endif - //#ifdef PLATFORM_X86_FAMILY - if ( F(1) == 'j' && F(2) == 'u' ) { Type = U64; Len += 2; } else - if ( F(1) == 'j' && F(2) == 'x' ) { Type = X64; Len += 2; } else { } - //#endif - - if ( Type == STRING ) - { - // TODO: This isn't efficient. - READY_FLUSH(); - const char* param = va_arg(Parameters, const char*); - Written += Print(param); - } - else if ( Type == CHAR ) - { - if ( READY_SIZE <= AmountReady ) { READY_FLUSH(); } - uint32_t param = va_arg(Parameters, uint32_t); - Ready[AmountReady] = param & 0xFF; AmountReady++; - } - else if ( Type == U32 ) - { - if ( READY_SIZE - AmountReady < 10 ) { READY_FLUSH(); } - uint32_t Num = va_arg(Parameters, uint32_t); - AmountReady += UInt32ToString(Num, Ready + AmountReady); - } - else if ( Type == U64 ) - { - if ( READY_SIZE - AmountReady < 20 ) { READY_FLUSH(); } - uint64_t Num = va_arg(Parameters, uint64_t); - AmountReady += UInt64ToString(Num, Ready + AmountReady); - } - else if ( Type == X32 ) - { - if ( READY_SIZE - AmountReady < 8 ) { READY_FLUSH(); } - uint32_t Num = va_arg(Parameters, uint32_t); - AmountReady += UInt32ToString16(Num, Ready + AmountReady); - } - else if ( Type == X64 ) - { - if ( READY_SIZE - AmountReady < 16 ) { READY_FLUSH(); } - uint64_t Num = va_arg(Parameters, uint64_t); - AmountReady += UInt64ToString16(Num, Ready + AmountReady); - } - else // Unsupported/unknown format. Just echo! - { - Ready[AmountReady] = *Format; AmountReady++; Written++; - } - - Format += Len; - } - - if ( READY_SIZE == AmountReady ) { READY_FLUSH(); } - } - - // Flush our cache. - if ( AmountReady ) { Ready[AmountReady] = 0; Written += Print(Ready); } - - return Written; - } -} diff --git a/sortix/iprintable.h b/sortix/iprintable.h deleted file mode 100644 index 57348f11..00000000 --- a/sortix/iprintable.h +++ /dev/null @@ -1,48 +0,0 @@ -/****************************************************************************** - - COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011. - - This file is part of Sortix. - - Sortix 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 (at your option) any later - version. - - Sortix 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 Sortix. If not, see . - - iprintable.h - A common interface shared by all devices that can be printed text to. - -******************************************************************************/ - -#ifndef SORTIX_IPRINTABLE_H -#define SORTIX_IPRINTABLE_H - -namespace Sortix -{ - int UInt8ToString(uint8_t Num, char* Dest); - int UInt16ToString(uint16_t Num, char* Dest); - int UInt32ToString(uint32_t Num, char* Dest); - int UInt64ToString(uint64_t Num, char* Dest); - - class IPrintable - { - public: - size_t PrintFV(const char* Format, va_list Parameters); - size_t PrintF(const char* Format, ...); - - public: - virtual size_t Print(const char* Message) = 0; - - }; -} - -#endif - diff --git a/sortix/isr.cpp b/sortix/isr.cpp index c01c72b8..aac28c84 100644 --- a/sortix/isr.cpp +++ b/sortix/isr.cpp @@ -5,8 +5,6 @@ // #include "platform.h" -#include "globals.h" -#include "iprintable.h" #include "iirqhandler.h" #include "log.h" #include "isr.h" diff --git a/sortix/kernel.cpp b/sortix/kernel.cpp index da1baf9f..32da950a 100644 --- a/sortix/kernel.cpp +++ b/sortix/kernel.cpp @@ -26,8 +26,6 @@ #include #include #include -#include "globals.h" -#include "iprintable.h" #include "log.h" #include "panic.h" #include "descriptor_tables.h" @@ -38,8 +36,6 @@ #include "memorymanagement.h" #include "scheduler.h" #include "syscall.h" -#include "pong.h" -#include "conway.h" #include "pci.h" #include "uart.h" #include "serialterminal.h" diff --git a/sortix/keyboard.cpp b/sortix/keyboard.cpp index d0524e7e..09b646e2 100644 --- a/sortix/keyboard.cpp +++ b/sortix/keyboard.cpp @@ -33,8 +33,6 @@ #include "process.h" #include "scheduler.h" -#include "pong.h" - using namespace Maxsi::Keyboard; namespace Sortix @@ -689,13 +687,6 @@ namespace Sortix QueueKeystroke(CodePoint); return; -#if PONG - Pong::OnKeystroke(CodePoint, KeyUp); return; -#endif - -#if 1 - return; -#endif //if ( Reader != NULL ) { Reader->OnKeystroke(CodePoint, KeyUp); return; } // Use this to debug the exact scancodes you receive! diff --git a/sortix/link.ld b/sortix/link.ld deleted file mode 100644 index bbb2ee00..00000000 --- a/sortix/link.ld +++ /dev/null @@ -1,33 +0,0 @@ -/* Link.ld -- Linker script for the kernel - ensure everything goes in the */ -/* Correct place. */ -/* Original file taken from Bran's Kernel Development */ -/* tutorials: http://www.osdever.net/bkerndev/index.php. */ - -ENTRY(start) -SECTIONS -{ - - .text 0x100000 : - { - code = .; _code = .; __code = .; - *(.text) - . = ALIGN(4096); - } - - .data : - { - data = .; _data = .; __data = .; - *(.data) - *(.rodata) - . = ALIGN(4096); - } - - .bss : - { - bss = .; _bss = .; __bss = .; - *(.bss) - . = ALIGN(4096); - } - - end = .; _end = .; __end = .; -} diff --git a/sortix/log.cpp b/sortix/log.cpp index f883fb52..5d67e181 100644 --- a/sortix/log.cpp +++ b/sortix/log.cpp @@ -25,188 +25,12 @@ #include "platform.h" #include #include -#include "globals.h" -#include "iprintable.h" #include "log.h" -#ifdef PLATFORM_SERIAL -#include "uart.h" -#endif - using namespace Maxsi; namespace Sortix { -#ifdef OLD_LOG - DEFINE_GLOBAL_OBJECT(Log, Log); - - void Log::Init() - { -#ifdef PLATFORM_SERIAL - // Set the cursor to (0,0) - const char InitMessage[] = { String::ASCII_ESCAPE, '[', 'H' }; - UART::Write(InitMessage, sizeof(InitMessage)); - - return; -#endif - - Line = 0; - Column = 0; - - // Empty the screen. - size_t* Msgs = (size_t*) Messages; - size_t Msg = ' '; -#ifdef PLATFORM_X86 - Msg |= Msg << 8; Msg |= Msg << 16; -#elif defined(PLATFORM_X64) - Msg |= Msg << 8; Msg |= Msg << 16; Msg |= Msg << 32; -#endif - for ( nat I = 0; I < (Height*Width) / sizeof(size_t); I++ ) { Msgs[I] = Msg; } - - // Set the color for each line. - for ( nat Y = 0; Y < Height; Y++ ) { Colors[Y] = (COLOR8_LIGHT_GREY << 0) + (COLOR8_BLACK << 4); } - - // Flush to our viewing device. - UpdateScreen(); - } - - void Log::UpdateScreen() - { -#ifdef PLATFORM_SERIAL - return; -#endif - - uint16_t* Destination = (uint16_t*) 0xB8000; - - // Copy and apply colors. - for ( nat Y = 0; Y < Height; Y++ ) - { - uint16_t Color = ((uint16_t) Colors[Y]) << 8; - - for ( nat X = 0; X < Width; X++ ) - { - Destination[X + Y*Width] = ( (uint16_t) Messages[X + Y*Width] ) | Color; - } - } - - SetCursor(Column, Line); - } - -#ifndef PLATFORM_SERIAL - size_t Log::Print(const char* Message) - { - size_t Written; - while ( *Message != '\0' /*&& *Message != 0*/ ) - { - if ( *Message == '\n' ) - { - NewLine(); - } - else if ( *Message == '\t' ) - { - if ( 80 <= Column ) { NewLine(); } - do { Messages[Column + Line * Width] = ' '; Column++; } while ( Column % 4 != 0 ); - } - else if ( *Message == '\r' ) - { - // No need for this driver to support line resets. - } - else if ( *Message == '\b' ) - { - // No need for this driver to support backspaces. - } - else - { - if ( 80 <= Column ) { NewLine(); } - Messages[Column + Line * Width] = *Message; Column++; - } - - Message++; - Written++; - } - - return Written; - } -#else - size_t Log::Print(const char* Message) - { - size_t Written; - while ( *Message != '\0' /*&& *Message != 0*/ ) - { - if ( *Message == '\n' ) - { - UART::WriteChar('\r'); - UART::WriteChar(*Message); - } - //else if ( *Message == '\t' ) - //{ - // if ( 80 <= Column ) { NewLine(); } - // do { Messages[Column + Line * Width] = ' '; Column++; } while ( Column % 4 != 0 ); - //} - else - { - UART::WriteChar(*Message); - } - - Message++; - Written++; - } - - return Written; - } -#endif - - void Log::NewLine() - { -#ifdef PLATFORM_SERIAL - return; -#endif - - if ( Line < Height - 1 ) - { - Line++; - } - else - { - // Scroll down our buffer. - Memory::Copy(Messages, Messages + Width, (Height-1)*Width); - - // Scroll down our color buffer as well. - for ( nat Y = 1; Y < Height; Y++ ) { Colors[Y-1] = Colors[Y]; } - } - - // Reset the new line. - Memory::Set(Messages + Line*Width, ' ', Width); - - // Assume the color of the new line is the same as the previous. - Colors[Line] = Colors[Line-1]; - - Column = 0; - - // Flush our output. - UpdateScreen(); - } - - void Log::SetCursor(nat X, nat Y) - { -#ifdef PLATFORM_SERIAL - return; -#endif - - nat Value = X + Y * Width; - - // This sends a command to indicies 14 and 15 in the - // CRT Control Register of the VGA controller. These - // are the high and low bytes of the index that show - // where the hardware cursor is to be 'blinking'. - CPU::OutPortB(0x3D4, 14); - CPU::OutPortB(0x3D5, (Value >> 8) & 0xFF); - CPU::OutPortB(0x3D4, 15); - CPU::OutPortB(0x3D5, (Value >> 0) & 0xFF); - } - - -#else namespace Log { Maxsi::Format::Callback deviceCallback = NULL; @@ -218,6 +42,4 @@ namespace Sortix devicePointer = user; } } - -#endif } diff --git a/sortix/log.h b/sortix/log.h index 95f598d2..1fb28abd 100644 --- a/sortix/log.h +++ b/sortix/log.h @@ -30,35 +30,6 @@ namespace Sortix { -#ifdef OLD_LOG - class Log : public IPrintable - { - protected: - const static nat Width = 80; - const static nat Height = 25; - char Messages[Width * Height]; - nat Column; - nat Line; - uint8_t Colors[Height]; - - public: - virtual void Init(); - - public: - void UpdateScreen(); - - public: - virtual size_t Print(const char* Message); - - private: - void NewLine(); - - public: - void SetCursor(nat X, nat Y); - }; - - DECLARE_GLOBAL_OBJECT(Log, Log); -#else namespace Log { extern Maxsi::Format::Callback deviceCallback; @@ -91,7 +62,6 @@ namespace Sortix return Maxsi::Format::Virtual(deviceCallback, devicePointer, format, list); } } -#endif } #endif diff --git a/sortix/pci.cpp b/sortix/pci.cpp index dd35c1bb..527cca2f 100644 --- a/sortix/pci.cpp +++ b/sortix/pci.cpp @@ -24,16 +24,12 @@ #include "platform.h" #include "pci.h" - -#include "globals.h" -#include "iprintable.h" #include "log.h" namespace Sortix { namespace PCI { - const uint16_t Config_Address = 0xCF8; const uint16_t Config_Data = 0xCFC; diff --git a/sortix/pong.cpp b/sortix/pong.cpp deleted file mode 100644 index 38d38638..00000000 --- a/sortix/pong.cpp +++ /dev/null @@ -1,311 +0,0 @@ -/****************************************************************************** - - COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011. - - This file is part of Sortix. - - Sortix 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 (at your option) any later - version. - - Sortix 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 Sortix. If not, see . - - pong.cpp - ROBOT PONG ATTACK! - -******************************************************************************/ - -#include "platform.h" -#include -#include "globals.h" -#include "iirqhandler.h" -#include "iprintable.h" -#include "keyboard.h" -#include "time.h" -#include "vga.h" -#include "sound.h" -#include "pong.h" - -#ifdef JSSORTIX -#include "uart.h" -#endif - -using namespace Maxsi; - -namespace Sortix -{ - namespace Pong - { - const int Height = 25; - const int Width = 80; - const int PadSize = 5; - - nat Time; - nat NextUpdate; - bool InIntro; - - int P1Y; - int P2Y; - bool P1VUP; - bool P2VUP; - bool P1VDOWN; - bool P2VDOWN; - nat P1Score; - nat P2Score; - nat HardCore; - - int BallX; - int BallY; - int VelX; - int VelY; - int OldBallX; - int OldBallY; - - int SoundLeft; - - const nat GoalFreq = 800; - const nat CollisionFreq = 1200; - - void Init() - { - ClearScreen(); - - P1Y = (Height-PadSize) / 5; - P2Y = (Height-PadSize) / 5; - P1VUP = false; - P2VUP = false; - P1VDOWN = false; - P2VDOWN = false; - - Time = 0; - - SoundLeft = -1; - - Reset(); -#ifndef JSSORTIX - Intro(); -#endif - } - - void Intro() - { - InIntro = true; - - ClearScreen(); - - uint16_t* Destination = (uint16_t*) 0xB8000; - - const char* String = "THIS IS SORTIX PONG"; size_t StringLen = String::Length(String); - const char* Warn = "SortixV3-beta Edition"; size_t WarnLen = String::Length(Warn); - const char* Enter = "-- press enter to continue --"; size_t EnterLen = String::Length(Enter); - - // Copy and apply colors. - uint16_t Color = COLOR8_GREEN << 8; - - for ( size_t I = 0; I < StringLen; I++ ) { Destination[Width / 2 - StringLen / 2 + I + (Height/2)*Width] = (uint16_t)(String[I]) | Color; } - for ( size_t I = 0; I < WarnLen; I++ ) { Destination[Width / 2 - WarnLen / 2 + I + (Height/2 + 1)*Width] = (uint16_t)(Warn[I]) | Color; } - for ( size_t I = 0; I < EnterLen; I++ ) { Destination[Width / 2 - EnterLen / 2 + I + (Height/2 + 2)*Width] = (uint16_t)(Enter[I]) | Color; } - - } - - void ClearScreen() - { - uint16_t* Destination = (uint16_t*) 0xB8000; - - // Copy and apply colors. - for ( int Y = 0; Y < Height; Y++ ) - { - uint16_t Color = COLOR8_BLACK << 8; - - for ( int X = 0; X < Width; X++ ) - { - Destination[X + Y*Width] = ' ' | Color; - } - } - } - - void Reset() - { - P1Score = 0; - P2Score = 0; - InIntro = false; - BallX = Width/2; - BallY = Height/2; - OldBallX = BallX; - OldBallY = BallY; - VelX = -1; - VelY = -1; - HardCore = 60; - UpdateUI(); - } - - void Collision() - { - Sound::Play(CollisionFreq); - SoundLeft = 40; - } - - void Goal(nat Player) - { - uint16_t* Destination = (uint16_t*) 0xB8000; - Destination[BallX + BallY*Width] = ' ' | (COLOR8_WHITE << 8); - - BallX = Width/2; - BallY = Height/2; - - if ( Player == 1 ) - { - VelX = 1; - VelY = 1; - P1Score++; - } - else if ( Player == 2 ) - { - VelX = -1; - VelY = -1; - P2Score++; - } - - Sound::Play(GoalFreq); - SoundLeft = 50; - - //HardCore -= 2; - - UpdateUI(); - } - - void UpdateUI() - { - uint16_t* Destination = (uint16_t*) 0xB8000; - - for ( int X = 0; X < Width; X++ ) { Destination[X] = ' ' | (COLOR8_LIGHT_GREY << 12) | (COLOR8_RED << 8); } - - char Num[12]; - int Len; - - Len = UInt32ToString(P1Score, Num); - for ( int I = 0; I < Len; I++ ) { Destination[I] = ( Destination[I] & 0xFF00 ) | Num[I]; } - - Len = UInt32ToString(P2Score, Num); - for ( int I = 0; I < Len; I++ ) { Destination[Width - Len + I] = ( Destination[Width - Len + I] & 0xFF00 ) | Num[I]; } - } - - void Update() - { -#ifdef JSSORTIX - - while ( true ) - { - int C = UART::TryPopChar(); - - if ( C == 'w' || C == 'W' ) { P1VUP = true; P1VDOWN = false; } - if ( C == 's' || C == 'S' ) { P1VDOWN = true; P1VUP = false; } - if ( C == 'o' || C == 'O' ) { P2VUP = true; P1VDOWN = false; } - if ( C == 'l' || C == 'L' ) { P2VDOWN = true; P2VUP = false; } - - if ( C == -1 ) { break; } - } -#endif - - uint16_t* Destination = (uint16_t*) 0xB8000; - - int P1V = 0, P2V = 0; - - if ( P1VUP && !P1VDOWN ) { P1V = -1; } else if ( !P1VUP && P1VDOWN ) { P1V = 1; } - if ( P2VUP && !P2VDOWN ) { P2V = -1; } else if ( !P2VUP && P2VDOWN ) { P2V = 1; } - - if ( P1V < 0 && P1Y > 1 ) { P1Y--; } - if ( P1V > 0 && P1Y + PadSize < Height ) { P1Y++; } - if ( P2V < 0 && P2Y > 1 ) { P2Y--; } - if ( P2V > 0 && P2Y + PadSize < Height ) { P2Y++; } - - for ( int Y = 1; Y < Height; Y++ ) - { - uint16_t Color = ( Y < P1Y || Y >= P1Y + PadSize ) ? COLOR8_BLACK << 12 : COLOR8_RED << 12; Destination[Y*Width] = ' ' | Color; - } - - for ( int Y = 1; Y < Height; Y++ ) - { - uint16_t Color = ( Y < P2Y || Y >= P2Y + PadSize ) ? COLOR8_BLACK << 12 : COLOR8_BLUE << 12; Destination[Width-1 + Y*Width] = ' ' | Color; - } - - if ( BallY + VelY <= 1 ) { VelY = 0 - VelY; Collision(); } - if ( BallY + VelY >= Height ) { VelY = 0 - VelY; Collision(); } - - if ( BallX + VelX < 1 ) { if ( BallY + VelY < P1Y - 1 || BallY + VelY > P1Y + PadSize + 1 ) { Goal(2); } else { VelX = 0 - VelX; Collision(); } } - if ( BallX + VelX >= Width-1 ) { if ( BallY + VelY < P2Y - 1 || BallY + VelY > P2Y + PadSize + 1 ) { Goal(1); } else { VelX = 0 - VelX; Collision(); } } - - Destination[OldBallX + OldBallY*Width] = ' ' | (COLOR8_WHITE << 8); - Destination[BallX + BallY*Width] = '.' | (COLOR8_WHITE << 8); - OldBallX = BallX; OldBallY = BallY; - - BallX += VelX; - BallY += VelY; - - Destination[BallX + BallY*Width] = 'o' | (COLOR8_WHITE << 8); - -#ifdef JSSORTIX - UART::RenderVGA(); - - P1VUP = P1VDOWN = P2VUP = P2VDOWN = false; -#endif - - NextUpdate = Time + HardCore; - } - - void OnKeystroke(uint32_t CodePoint, bool KeyUp) - { - const uint32_t UP = 0xFFFFFFFF - 20; - const uint32_t DOWN = 0xFFFFFFFF - 23; - - if ( CodePoint == '\n' ) - { - ClearScreen(); - Reset(); - Update(); - } - - if ( CodePoint == 'w' || CodePoint == 'W' ) { P1VUP = !KeyUp; } - if ( CodePoint == 's' || CodePoint == 'S' ) { P1VDOWN = !KeyUp; } - if ( CodePoint == UP ) { P2VUP = !KeyUp; } - if ( CodePoint == DOWN ) { P2VDOWN = !KeyUp; } - } - - void OnFuture() - { - const int TimePassed = 10; - - Time += TimePassed; - -#ifdef JSSORTIX - // Artificially display the boot welcome screen. - if ( Time < 2000 ) { return; } -#endif - - if ( SoundLeft > 0 ) - { - if ( SoundLeft <= TimePassed ) - { - Sound::Mute(); - SoundLeft = -1; - } - else - { - SoundLeft -= TimePassed; - } - } - - if ( InIntro ) { return; } - - if ( NextUpdate <= Time ) { Update(); } - } - } -} diff --git a/sortix/pong.h b/sortix/pong.h deleted file mode 100644 index 0f992f01..00000000 --- a/sortix/pong.h +++ /dev/null @@ -1,45 +0,0 @@ -/****************************************************************************** - - COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011. - - This file is part of Sortix. - - Sortix 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 (at your option) any later - version. - - Sortix 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 Sortix. If not, see . - - pong.h - ROBOT PONG ATTACK! - -******************************************************************************/ - -#ifndef SORTIX_PONG_H -#define SORTIX_PONG_H - -namespace Sortix -{ - namespace Pong - { - void Init(); - void Intro(); - void ClearScreen(); - void Reset(); - void Goal(nat Player); - void Update(); - void UpdateUI(); - void OnKeystroke(uint32_t CodePoint, bool KeyUp); - void OnFuture(); - }; -} - -#endif - diff --git a/sortix/scheduler.cpp b/sortix/scheduler.cpp index e411e83a..231ca5d9 100644 --- a/sortix/scheduler.cpp +++ b/sortix/scheduler.cpp @@ -26,12 +26,10 @@ #include #include "panic.h" #include "scheduler.h" -#include "globals.h" #include "multiboot.h" #include "memorymanagement.h" #include "descriptor_tables.h" -#include "iprintable.h" #include "log.h" #include "sound.h" // HACK diff --git a/sortix/shell.cpp b/sortix/shell.cpp deleted file mode 100644 index 23332887..00000000 --- a/sortix/shell.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/****************************************************************************** - - COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011. - - This file is part of Sortix. - - Sortix 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 (at your option) any later - version. - - Sortix 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 Sortix. If not, see . - - shell.cpp - A very basic command line shell. - -******************************************************************************/ - -#include "platform.h" -#include -#include -#include "globals.h" -#include "iprintable.h" -#include "iirqhandler.h" -#include "log.h" -#include "keyboard.h" -#include "shell.h" - -using namespace Maxsi; - -namespace Sortix -{ - DEFINE_GLOBAL_OBJECT(Shell, Shell); - - const char* Prefix = "root@sortix / # "; - - void Shell::Init() - { - BacklogUsed = 0; - Column = 0; - - // Empty the screen. -#ifdef PLATFORM_X86 - size_t Msg = ' '; Msg |= Msg << 8; Msg |= Msg << 16; -#elif defined(PLATFORM_X64) - size_t Msg = ' '; Msg |= Msg << 8; Msg |= Msg << 16; Msg |= Msg << 32; -#endif - for ( nat I = 0; I < (BacklogHeight*Width) / sizeof(size_t); I++ ) { Backlog[I] = Msg; } - for ( nat I = 0; I < (Height*Width) / sizeof(size_t); I++ ) { Command[I] = Msg; } - - // Flush to our viewing device. - UpdateScreen(); - } - - void Shell::ClearScreen() - { - uint16_t* Destination = (uint16_t*) 0xB8000; - - for ( size_t I = 0; I < (Height*Width)/sizeof(size_t); I++ ) { Destination[I] = 0; } - } - - void Shell::UpdateScreen() - { - ClearScreen(); - - uint16_t* Destination = (uint16_t*) 0xB8000; - - uint16_t Color = ((COLOR8_LIGHT_GREY << 0) + (COLOR8_BLACK << 4)) << 8; - - nat CommandLines = (Column + String::Length(Prefix)) / Width + 1; - - nat BacklogLines = Height - CommandLines; if ( BacklogUsed < BacklogLines ) { BacklogLines = BacklogUsed; } - for ( nat I = 0; I < BacklogLines; I++ ) - { - nat Line = BacklogUsed - BacklogLines + I; - - for ( nat X = 0; X < Width; X++ ) { Destination[X + I*Width] = ( (uint16_t) Backlog[X + Line*Width] ) | Color; } - } - - uint16_t* Pos = Destination + Width * BacklogLines; - - size_t PrefixLen = String::Length(Prefix); - for ( size_t I = 0; I < PrefixLen; I++ ) { Pos[I] = ( (uint16_t) Prefix[I] ) | Color; } - Pos += PrefixLen; - for ( size_t I = 0; I < Column; I++ ) { Pos[I] = ( (uint16_t) Command[I] ) | Color; } - - SetCursor((PrefixLen + Column) % Width, BacklogLines + CommandLines - 1); - } - - void Shell::OnKeystroke(uint32_t CodePoint, bool KeyUp) - { - if ( CodePoint == '\n' ) - { - //Execute(); - } - else if ( CodePoint == '\t' ) - { - // No autocompletion yet! - } - else if ( CodePoint == '\r' ) - { - // No need for this driver to support line resets. - } - else if ( CodePoint == '\b' ) - { - if ( 0 < Column ) { Column--; } - } - else - { - if ( CodePoint <= 0xFF ) - { - Command[Column] = CodePoint; Column++; - } - } - - UpdateScreen(); - } - -#if 0 - void Shell::NewLine() - { - if ( Line < Height - 1 ) - { - Line++; - } - else - { - // Scroll down our buffer. - Memory::Copy(Messages, Messages + Width, (Height-1)*Width); - - // Scroll down our color buffer as well. - for ( nat Y = 1; Y < Height; Y++ ) { Colors[Y-1] = Colors[Y]; } - } - - // Reset the new line. - Memory::Set(Messages + Line*Width, ' ', Width); - - // Assume the color of the new line is the same as the previous. - Colors[Line] = Colors[Line-1]; - - Column = 0; - - // Flush our output. - UpdateScreen(); - } -#endif - - void Shell::SetCursor(nat X, nat Y) - { - nat Value = X + Y * Width; - - // This sends a command to indicies 14 and 15 in the - // CRT Control Register of the VGA controller. These - // are the high and low bytes of the index that show - // where the hardware cursor is to be 'blinking'. - X86::OutPortB(0x3D4, 14); - X86::OutPortB(0x3D5, (Value >> 8) & 0xFF); - X86::OutPortB(0x3D4, 15); - X86::OutPortB(0x3D5, (Value >> 0) & 0xFF); - } -} diff --git a/sortix/shell.h b/sortix/shell.h deleted file mode 100644 index 1e0d8736..00000000 --- a/sortix/shell.h +++ /dev/null @@ -1,62 +0,0 @@ -/****************************************************************************** - - COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011. - - This file is part of Sortix. - - Sortix 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 (at your option) any later - version. - - Sortix 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 Sortix. If not, see . - - shell.h - A very basic command line shell. - -******************************************************************************/ - -#ifndef SORTIX_SHELL_H -#define SORTIX_SHELL_H - -namespace Sortix -{ - class Shell : public IKeystrokable - { - protected: - const static nat Width = 80; - const static nat BacklogHeight = 100; - const static nat Height = 25; - char Backlog[Width * BacklogHeight]; - char Command[Width * Height]; - nat BacklogUsed; - nat Column; - nat Scroll; - - public: - virtual void Init(); - - private: - void ClearScreen(); - - public: - void UpdateScreen(); - - public: - virtual void OnKeystroke(uint32_t CodePoint, bool KeyUp); - - public: - void SetCursor(nat X, nat Y); - }; - - DECLARE_GLOBAL_OBJECT(Shell, Shell); -} - -#endif - diff --git a/sortix/syscall.cpp b/sortix/syscall.cpp index 212c3e9f..227fb7ee 100644 --- a/sortix/syscall.cpp +++ b/sortix/syscall.cpp @@ -27,8 +27,6 @@ #include "scheduler.h" #include "iirqhandler.h" #include "isr.h" -#include "globals.h" -#include "iprintable.h" #include "log.h" #include "panic.h" #include "vga.h" diff --git a/sortix/test.cpp b/sortix/test.cpp deleted file mode 100644 index 190a66b3..00000000 --- a/sortix/test.cpp +++ /dev/null @@ -1,12 +0,0 @@ -#include "platform.h" -#include "globals.h" -#include "iprintable.h" -#include "log.h" - -namespace Sortix -{ - void foo(int bar, unsigned int qux) - { - Log::PrintF("Hello, %i, and %u!", bar, qux); - } -} diff --git a/sortix/time.cpp b/sortix/time.cpp index 2486b936..a4f79b4b 100644 --- a/sortix/time.cpp +++ b/sortix/time.cpp @@ -28,9 +28,6 @@ #include "iirqhandler.h" #include "isr.h" #include "scheduler.h" - -#include "globals.h" -#include "iprintable.h" #include "log.h" #if !defined(PLATFORM_X86_FAMILY) diff --git a/sortix/types.h b/sortix/types.h deleted file mode 100644 index 7f0d76aa..00000000 --- a/sortix/types.h +++ /dev/null @@ -1,101 +0,0 @@ -/****************************************************************************** - - COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011. - - This file is part of LibMaxsi. - - LibMaxsi is free software: you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the Free - Software Foundation, either version 3 of the License, or (at your option) - any later version. - - LibMaxsi 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 Lesser General Public License for - more details. - - You should have received a copy of the GNU Lesser General Public License - along with LibMaxsi. If not, see . - - types.h - Declares the required datatypes for the x86 architecture. - -******************************************************************************/ - -#ifndef SORTIX_TYPES_H -#define SORTIX_TYPES_H - -// TODO: Declare stuff from . - -#undef NULL -#if defined(__cplusplus) - #define NULL 0 -#else - #define NULL ((void*) 0) - typedef int wchar_t; -#endif - -// Define basic signed types. -typedef char int8_t; -typedef short int16_t; -typedef int int32_t; -typedef long long int64_t; - -// Define basic unsigned types. -typedef unsigned char uint8_t; -typedef unsigned short uint16_t; -typedef unsigned int uint32_t; -typedef unsigned long long uint64_t; - -typedef unsigned int nat; - -// The maximum width integers available on this platform. -typedef int64_t intmax_t; -typedef uint64_t uintmax_t; - -// Define an integer able to hold the size of the largest continious memory -// region and define pointer safe integer types. -// TODO: 64-bit datatypes. Need to figure out which ifdef to use! -typedef unsigned int size_t; -typedef signed int ssize_t; -typedef signed int intptr_t; -typedef unsigned int uintptr_t; -typedef signed int ptrdiff_t; - -#define INT8_MIN (0x80) -#define INT16_MIN (0x8000) -#define INT32_MIN (0x80000000) -#define INT64_MIN (0x8000000000000000ULL) -#define INT8_MAX (0x7F) -#define INT16_MAX (0x7FFF) -#define INT32_MAX (0x7FFFFFFF) -#define INT64_MAX (0x7FFFFFFFFFFFFFFFULL) -#define UINT8_MAX (0xFF) -#define UINT16_MAX (0xFFFF) -#define UINT32_MAX (0xFFFFFFFF) -#define UINT64_MAX (0xFFFFFFFFFFFFFFFFULL) - -#define INTMAX_MIN INT64_MIN -#define INTMAX_MAX INT64_MAX -#define UINTMAX_MAX UINT64_MAX - -#ifdef PLATFORM_X86 - #define SSIZE_MIN INT32_MIN - #define SSIZE_MAX INT32_MAX - #define SIZE_MAX UINT32_MAX - #define INTPTR_MIN INT32_MIN - #define INTPTR_MAX INT32_MAX - #define UINTPTR_MAX UINT32_MAX -#elif defined(PLATFORM_X64) - #define SSIZE_MIN INT64_MIN - #define SSIZE_MAX INT64_MAX - #define SIZE_MAX UINT64_MAX - #define INTPTR_MIN INT64_MIN - #define INTPTR_MAX INT64_MAX - #define UINTPTR_MAX UINT64_MAX -#endif - -typedef int wint_t; - -#endif -