mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Made Sortix compatible with gcc 4.6.1.
This commit fixes some instances of uninitialized memory. In addition, the bootstrap tables for x64 are moved around a bit, in this awful game of placing stuff where it won't collide with grub.
This commit is contained in:
parent
2b3b4ed62a
commit
7bc1fa259e
4 changed files with 27 additions and 23 deletions
|
@ -23,6 +23,7 @@
|
|||
******************************************************************************/
|
||||
|
||||
#include "platform.h"
|
||||
#include <libmaxsi/memory.h>
|
||||
#include "panic.h"
|
||||
#include "thread.h"
|
||||
#include "process.h"
|
||||
|
@ -53,7 +54,7 @@ namespace Sortix
|
|||
namespace Scheduler
|
||||
{
|
||||
byte dummythreaddata[sizeof(Thread)];
|
||||
Thread* dummythread = (Thread*) &dummythreaddata;
|
||||
Thread* dummythread;
|
||||
Thread* currentthread;
|
||||
Thread* idlethread;
|
||||
Thread* firstrunnablethread;
|
||||
|
@ -67,6 +68,8 @@ namespace Sortix
|
|||
// currentthread is accessed. This lets us avoid checking whether
|
||||
// currentthread is NULL (which it only will be once) which gives
|
||||
// simpler code.
|
||||
dummythread = (Thread*) &dummythreaddata;
|
||||
Maxsi::Memory::Set(dummythread, 0, sizeof(*dummythread));
|
||||
currentthread = dummythread;
|
||||
firstrunnablethread = NULL;
|
||||
firstsleepingthread = NULL;
|
||||
|
|
|
@ -41,8 +41,8 @@ namespace Sortix
|
|||
{
|
||||
CPU::SyscallRegisters* syscall_state_ptr;
|
||||
unsigned system_was_incomplete;
|
||||
size_t SYSCALL_MAX = SYSCALL_MAX_NUM;
|
||||
void* syscall_list[SYSCALL_MAX_NUM];
|
||||
size_t SYSCALL_MAX;
|
||||
volatile void* syscall_list[SYSCALL_MAX_NUM];
|
||||
}
|
||||
|
||||
int BadSyscall()
|
||||
|
@ -53,7 +53,8 @@ namespace Sortix
|
|||
|
||||
void Init()
|
||||
{
|
||||
for ( size_t i = 0; i < SYSCALL_MAX; i++ )
|
||||
SYSCALL_MAX = SYSCALL_MAX_NUM;
|
||||
for ( size_t i = 0; i < SYSCALL_MAX_NUM; i++ )
|
||||
{
|
||||
syscall_list[i] = (void*) BadSyscall;
|
||||
}
|
||||
|
@ -61,10 +62,10 @@ namespace Sortix
|
|||
|
||||
void Register(size_t index, void* funcptr)
|
||||
{
|
||||
if ( SYSCALL_MAX <= index )
|
||||
if ( SYSCALL_MAX_NUM <= index )
|
||||
{
|
||||
PanicF("attempted to register syscall 0x%p to index %zu, but "
|
||||
"SYSCALL_MAX = %zu", funcptr, index, SYSCALL_MAX);
|
||||
"SYSCALL_MAX_NYN = %zu", funcptr, index, SYSCALL_MAX_NUM);
|
||||
}
|
||||
|
||||
syscall_list[index] = funcptr;
|
||||
|
|
|
@ -57,8 +57,8 @@ multiboot_entry:
|
|||
# Store the magic value.
|
||||
mov %eax, 0x100004
|
||||
|
||||
# Clear the first $0xE000 bytes following 0x1000.
|
||||
movl $0x1000, %edi
|
||||
# Clear the first $0xE000 bytes following 0x21000.
|
||||
movl $0x21000, %edi
|
||||
mov %edi, %cr3
|
||||
xorl %eax, %eax
|
||||
movl $0xE000, %ecx
|
||||
|
@ -70,16 +70,16 @@ multiboot_entry:
|
|||
# first 2 MiB. We also do this with 0x200 to allow forking the page.
|
||||
|
||||
# Page-Map Level 4
|
||||
movl $0x2207, (%edi)
|
||||
movl $0x22207, (%edi)
|
||||
addl $0x1000, %edi
|
||||
|
||||
# Page-Directory Pointer Table
|
||||
movl $0x3207, (%edi)
|
||||
movl $0x23207, (%edi)
|
||||
addl $0x1000, %edi
|
||||
|
||||
# Page-Directory (no user-space access here)
|
||||
movl $0x4203, (%edi) # (First 2 MiB)
|
||||
movl $0x5203, 8(%edi) # (Second 2 MiB)
|
||||
movl $0x24203, (%edi) # (First 2 MiB)
|
||||
movl $0x25203, 8(%edi) # (Second 2 MiB)
|
||||
addl $0x1000, %edi
|
||||
|
||||
# Page-Table
|
||||
|
|
|
@ -51,10 +51,10 @@ namespace Sortix
|
|||
// to zeroes. Since these structures are already used, doing it here
|
||||
// will be very dangerous.
|
||||
|
||||
PML* const BOOTPML4 = (PML* const) 0x01000UL;
|
||||
PML* const BOOTPML3 = (PML* const) 0x06000UL;
|
||||
PML* const BOOTPML2 = (PML* const) 0x07000UL;
|
||||
PML* const BOOTPML1 = (PML* const) 0x08000UL;
|
||||
PML* const BOOTPML4 = (PML* const) 0x21000UL;
|
||||
PML* const BOOTPML3 = (PML* const) 0x26000UL;
|
||||
PML* const BOOTPML2 = (PML* const) 0x27000UL;
|
||||
PML* const BOOTPML1 = (PML* const) 0x28000UL;
|
||||
|
||||
// First order of business is to map the virtual memory structures
|
||||
// to the pre-defined locations in the virtual address space.
|
||||
|
@ -76,8 +76,8 @@ namespace Sortix
|
|||
BOOTPML1->entry[511] = (addr_t) BOOTPML4 | flags;
|
||||
|
||||
// Add some predefined room for forking address spaces.
|
||||
PML* const FORKPML2 = (PML* const) 0x09000UL;
|
||||
PML* const FORKPML1 = (PML* const) 0x0A000UL;
|
||||
PML* const FORKPML2 = (PML* const) 0x29000UL;
|
||||
PML* const FORKPML1 = (PML* const) 0x2A000UL;
|
||||
|
||||
BOOTPML3->entry[0] = (addr_t) FORKPML2 | flags | PML_FORK;
|
||||
BOOTPML2->entry[0] = (addr_t) FORKPML1 | flags | PML_FORK;
|
||||
|
@ -89,10 +89,10 @@ namespace Sortix
|
|||
// course, we still have no physical page allocator, so that's the
|
||||
// next step.
|
||||
|
||||
PML* const PHYSPML3 = (PML* const) 0x0B000UL;
|
||||
PML* const PHYSPML2 = (PML* const) 0x0C000UL;
|
||||
PML* const PHYSPML1 = (PML* const) 0x0D000UL;
|
||||
PML* const PHYSPML0 = (PML* const) 0x0E000UL;
|
||||
PML* const PHYSPML3 = (PML* const) 0x2B000UL;
|
||||
PML* const PHYSPML2 = (PML* const) 0x2C000UL;
|
||||
PML* const PHYSPML1 = (PML* const) 0x2D000UL;
|
||||
PML* const PHYSPML0 = (PML* const) 0x2E000UL;
|
||||
|
||||
BOOTPML4->entry[509] = (addr_t) PHYSPML3 | flags;
|
||||
PHYSPML3->entry[0] = (addr_t) PHYSPML2 | flags;
|
||||
|
@ -140,7 +140,7 @@ namespace Sortix
|
|||
// Switch to the address space from when the world was originally
|
||||
// created. It should contain the kernel, the whole kernel, and
|
||||
// nothing but the kernel.
|
||||
PML* const BOOTPML4 = (PML* const) 0x01000UL;
|
||||
PML* const BOOTPML4 = (PML* const) 0x21000UL;
|
||||
SwitchAddressSpace((addr_t) BOOTPML4);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue