diff --git a/AK/StringImpl.cpp b/AK/StringImpl.cpp index 396d556851552b..579ef4db90c2dd 100644 --- a/AK/StringImpl.cpp +++ b/AK/StringImpl.cpp @@ -21,15 +21,6 @@ namespace AK { static StringImpl* s_the_empty_stringimpl = nullptr; -void StringImpl::initialize_globals() -{ - s_the_empty_stringimpl = nullptr; -#ifdef DEBUG_STRINGIMPL - g_stringimpl_count = 0; - g_all_live_stringimpls = new HashTable; -#endif -} - StringImpl& StringImpl::the_empty_stringimpl() { if (!s_the_empty_stringimpl) diff --git a/AK/StringImpl.h b/AK/StringImpl.h index 8b916e42a70c24..aba8ea8d4bb725 100644 --- a/AK/StringImpl.h +++ b/AK/StringImpl.h @@ -17,7 +17,6 @@ class StringImpl : public Retainable { RetainPtr to_uppercase() const; static StringImpl& the_empty_stringimpl(); - static void initialize_globals(); ~StringImpl(); diff --git a/Kernel/BochsVGADevice.cpp b/Kernel/BochsVGADevice.cpp index 83cdad488273ac..58c94a17fcccac 100644 --- a/Kernel/BochsVGADevice.cpp +++ b/Kernel/BochsVGADevice.cpp @@ -24,11 +24,6 @@ BochsVGADevice& BochsVGADevice::the() return *s_the; } -void BochsVGADevice::initialize_statics() -{ - s_the = nullptr; -} - BochsVGADevice::BochsVGADevice() { s_the = this; diff --git a/Kernel/BochsVGADevice.h b/Kernel/BochsVGADevice.h index eb4b9692df4f12..ab5bf503f2ab7b 100644 --- a/Kernel/BochsVGADevice.h +++ b/Kernel/BochsVGADevice.h @@ -10,7 +10,6 @@ class BochsVGADevice { AK_MAKE_ETERNAL public: static BochsVGADevice& the(); - static void initialize_statics(); BochsVGADevice(); diff --git a/Kernel/Boot/boot.asm b/Kernel/Boot/boot.asm index fdd0027e94a3ac..76cc7da19a46b3 100755 --- a/Kernel/Boot/boot.asm +++ b/Kernel/Boot/boot.asm @@ -25,9 +25,13 @@ boot: mov ax, 0x2401 int 0x15 - mov bx, 0x1000 + ; HACK: Load the ELF kernel at 0xf000. Assuming that the first + ; LOAD header has a file offset of 0x1000, this puts _start + ; at 0x10000 which we jump to later. + ; This is all quite rickety. + mov bx, 0xf00 mov es, bx - xor bx, bx ; Load kernel @ 0x10000 + xor bx, bx mov cx, word [cur_lba] .sector_loop: @@ -65,6 +69,53 @@ boot: xor al, al out dx, al + ; Let's look at the ELF header. + mov bx, 0xf00 + mov fs, bx + cmp [fs:0], dword 0x464c457f ; ELF magic: { 0x7f "ELF" } + jne fug + + cmp [fs:24], dword 0x10000 ; Entry should be 0x10000 + jne fug + + mov ebx, dword [fs:28] ; EBX <- program header table + mov ecx, dword [fs:44] ; ECX <- program header count + +; Let's find the BSS and clear it. + +parse_program_header: + cmp [fs:ebx], dword 0x1 ; Is Load segment? + jne .next + + cmp [fs:ebx+24], dword 0x6 ; Is read+write but not execute? + jne .next + + mov edi, [fs:ebx+8] ; EDI <- p_vaddr + add edi, [fs:ebx+16] ; skip over 'p_filesz' bytes (leave them intact) + + push ecx + + sub edi, [fs:ebx+16] ; skip over 'p_filesz' bytes (see above) + + ; Since we're in 16-bit real mode, create a segment address. + mov eax, edi + shr eax, 4 + mov es, ax + and edi, 0xf + + mov ecx, [fs:ebx+20] ; ECX <- p_memsz + xor al, al + rep stosb + + pop ecx + +.next: + add ebx, 32 + loop parse_program_header + +; Okay we're all set to go! + +lets_go: lgdt [cs:test_gdt_ptr] mov eax, cr0 @@ -182,7 +233,7 @@ convert_lba_to_chs: ret cur_lba: - dw 9 + dw 1 sectors_per_track: dw 18 heads: diff --git a/Kernel/FileSystem.cpp b/Kernel/FileSystem.cpp index a02828230cbe42..855ba34d9c0d42 100644 --- a/Kernel/FileSystem.cpp +++ b/Kernel/FileSystem.cpp @@ -23,13 +23,6 @@ HashTable& all_inodes() return *s_inode_set; } -void FS::initialize_globals() -{ - s_lastFileSystemID = 0; - s_fs_map = nullptr; - s_inode_set = nullptr; -} - FS::FS() : m_fsid(++s_lastFileSystemID) { diff --git a/Kernel/FileSystem.h b/Kernel/FileSystem.h index 8a4f90465ed3e2..58a24d25cbf0b1 100644 --- a/Kernel/FileSystem.h +++ b/Kernel/FileSystem.h @@ -23,7 +23,6 @@ class VMObject; class FS : public Retainable { public: - static void initialize_globals(); virtual ~FS(); unsigned fsid() const { return m_fsid; } diff --git a/Kernel/PTYMultiplexer.cpp b/Kernel/PTYMultiplexer.cpp index 15959e1b3f4375..75e5a2e26e23e2 100644 --- a/Kernel/PTYMultiplexer.cpp +++ b/Kernel/PTYMultiplexer.cpp @@ -12,11 +12,6 @@ PTYMultiplexer& PTYMultiplexer::the() return *s_the; } -void PTYMultiplexer::initialize_statics() -{ - s_the = nullptr; -} - PTYMultiplexer::PTYMultiplexer() : CharacterDevice(5, 2) { diff --git a/Kernel/PTYMultiplexer.h b/Kernel/PTYMultiplexer.h index c2062c2db74d94..064d3eb00f01de 100644 --- a/Kernel/PTYMultiplexer.h +++ b/Kernel/PTYMultiplexer.h @@ -13,7 +13,6 @@ class PTYMultiplexer final : public CharacterDevice { virtual ~PTYMultiplexer() override; static PTYMultiplexer& the(); - static void initialize_statics(); // ^CharacterDevice virtual RetainPtr open(int& error, int options) override; diff --git a/Kernel/ProcessGUI.cpp b/Kernel/ProcessGUI.cpp index 8bdbd565d4806f..d93c7079fa4d9e 100644 --- a/Kernel/ProcessGUI.cpp +++ b/Kernel/ProcessGUI.cpp @@ -12,11 +12,6 @@ void Process::initialize_gui_statics() { - Font::initialize(); - WSMessageLoop::initialize(); - WSWindowManager::initialize(); - WSScreen::initialize(); - new WSMessageLoop; } diff --git a/Kernel/VirtualFileSystem.cpp b/Kernel/VirtualFileSystem.cpp index 15cc406394fef4..10b843be5d593f 100644 --- a/Kernel/VirtualFileSystem.cpp +++ b/Kernel/VirtualFileSystem.cpp @@ -19,12 +19,6 @@ VFS& VFS::the() return *s_the; } -void VFS::initialize_globals() -{ - s_the = nullptr; - FS::initialize_globals(); -} - VFS::VFS() { #ifdef VFS_DEBUG diff --git a/Kernel/VirtualFileSystem.h b/Kernel/VirtualFileSystem.h index 758ce13028b213..6c3fe71c40836a 100644 --- a/Kernel/VirtualFileSystem.h +++ b/Kernel/VirtualFileSystem.h @@ -39,8 +39,6 @@ class VFS; class VFS { AK_MAKE_ETERNAL public: - static void initialize_globals(); - class Mount { public: Mount(InodeIdentifier host, RetainPtr&&); diff --git a/Kernel/init.cpp b/Kernel/init.cpp index 655c1307bca024..47f001835761ec 100644 --- a/Kernel/init.cpp +++ b/Kernel/init.cpp @@ -151,8 +151,6 @@ void init() gdt_init(); idt_init(); - PTYMultiplexer::initialize_statics(); - VFS::initialize_globals(); vfs = new VFS; keyboard = new Keyboard; @@ -169,10 +167,6 @@ void init() kprintf("Starting Serenity Operating System...\n"); MemoryManager::initialize(); - - StringImpl::initialize_globals(); - BochsVGADevice::initialize_statics(); - PIT::initialize(); memset(&system, 0, sizeof(system)); diff --git a/LibC/entry.cpp b/LibC/entry.cpp index 8fd78e3e644059..393aec2ddcdf1a 100644 --- a/LibC/entry.cpp +++ b/LibC/entry.cpp @@ -18,8 +18,6 @@ extern "C" int _start() __stdio_init(); __malloc_init(); - StringImpl::initialize_globals(); - int status = 254; int argc; char** argv; diff --git a/SharedGraphics/Font.cpp b/SharedGraphics/Font.cpp index 3e3f11a6b9dbd4..a7c5e8997faedd 100644 --- a/SharedGraphics/Font.cpp +++ b/SharedGraphics/Font.cpp @@ -50,12 +50,6 @@ static inline constexpr size_t font_file_size(unsigned glyph_height) return sizeof(FontFileHeader) + 256 * sizeof(dword) * glyph_height; } -void Font::initialize() -{ - s_default_font = nullptr; - s_default_bold_font = nullptr; -} - Font& Font::default_font() { static const char* default_font_path = "/res/fonts/LizaRegular8x10.font"; diff --git a/SharedGraphics/Font.h b/SharedGraphics/Font.h index ebc64b6930d37d..20b7dcfe7f05ac 100644 --- a/SharedGraphics/Font.h +++ b/SharedGraphics/Font.h @@ -62,8 +62,6 @@ class Font : public Retainable { String name() const { return m_name; } void set_name(const String& name) { m_name = name; } - static void initialize(); - private: Font(const String& name, unsigned* rows, byte glyph_width, byte glyph_height); diff --git a/WindowServer/WSMessageLoop.cpp b/WindowServer/WSMessageLoop.cpp index 00f4b9a63bc3fe..3d5a505b3bfbc8 100644 --- a/WindowServer/WSMessageLoop.cpp +++ b/WindowServer/WSMessageLoop.cpp @@ -12,11 +12,6 @@ static WSMessageLoop* s_the; -void WSMessageLoop::initialize() -{ - s_the = nullptr; -} - WSMessageLoop::WSMessageLoop() { if (!s_the) diff --git a/WindowServer/WSMessageLoop.h b/WindowServer/WSMessageLoop.h index 0d232b7c7b738d..ed7412d5c8d9f7 100644 --- a/WindowServer/WSMessageLoop.h +++ b/WindowServer/WSMessageLoop.h @@ -19,8 +19,6 @@ class WSMessageLoop { static WSMessageLoop& the(); - static void initialize(); - bool running() const { return m_running; } Process& server_process() { return *m_server_process; } diff --git a/WindowServer/WSScreen.cpp b/WindowServer/WSScreen.cpp index c53ee7a6899751..5e48e16a6f6e3c 100644 --- a/WindowServer/WSScreen.cpp +++ b/WindowServer/WSScreen.cpp @@ -7,11 +7,6 @@ static WSScreen* s_the; -void WSScreen::initialize() -{ - s_the = nullptr; -} - WSScreen& WSScreen::the() { ASSERT(s_the); diff --git a/WindowServer/WSScreen.h b/WindowServer/WSScreen.h index bc957b7b542fd8..35f42a1cd153cc 100644 --- a/WindowServer/WSScreen.h +++ b/WindowServer/WSScreen.h @@ -21,8 +21,6 @@ class WSScreen { Size size() const { return { width(), height() }; } Rect rect() const { return { 0, 0, width(), height() }; } - static void initialize(); - Point cursor_location() const { return m_cursor_location; } bool left_mouse_button_pressed() const { return m_left_mouse_button_pressed; } bool right_mouse_button_pressed() const { return m_right_mouse_button_pressed; } diff --git a/WindowServer/WSWindowManager.cpp b/WindowServer/WSWindowManager.cpp index 4a8c3403129437..6b5b4b2a8abd57 100644 --- a/WindowServer/WSWindowManager.cpp +++ b/WindowServer/WSWindowManager.cpp @@ -75,11 +75,6 @@ WSWindowManager& WSWindowManager::the() return *s_the; } -void WSWindowManager::initialize() -{ - s_the = nullptr; -} - static const char* cursor_bitmap_inner_ascii = { " # " " ## " diff --git a/WindowServer/WSWindowManager.h b/WindowServer/WSWindowManager.h index dd3a7b17f3a56a..328ba3d8979937 100644 --- a/WindowServer/WSWindowManager.h +++ b/WindowServer/WSWindowManager.h @@ -29,8 +29,6 @@ class WSWindowManager : public WSMessageReceiver { void move_to_front(WSWindow&); - static void initialize(); - void draw_cursor(); void invalidate(const WSWindow&);