mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Restored the partial support for x64.
This commit is contained in:
parent
371dec71c9
commit
4bc2841ef0
8 changed files with 50 additions and 15 deletions
|
@ -715,6 +715,7 @@ namespace Sortix
|
|||
|
||||
void SysReceieveKeystroke(CPU::InterruptRegisters* R)
|
||||
{
|
||||
#ifdef PLATFORM_X86
|
||||
uint32_t codepoint;
|
||||
if ( keystrokeQueueUsed == 0 )
|
||||
{
|
||||
|
@ -728,6 +729,7 @@ namespace Sortix
|
|||
keystrokeQueueUsed--;
|
||||
}
|
||||
R->eax = codepoint;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -131,6 +131,8 @@ namespace Sortix
|
|||
|
||||
#ifdef PLATFORM_X64
|
||||
Log::Print("Halt: CPU X64 cannot continue as the virtual memory isn't disabled (kernel bug) and the code is about to access non-mapped memory.\n");
|
||||
Log::Print("Sorry, it simply isn't possible to fully boot Sortix in x64 mode yet.\n");
|
||||
Log::Print("X64 may be working when Sortix 0.5 comes out, or try the git master.\n");
|
||||
while(true);
|
||||
#endif
|
||||
|
||||
|
@ -627,11 +629,21 @@ namespace Sortix
|
|||
|
||||
#warning "Virtual Memory is not available on this arch"
|
||||
|
||||
addr_t Lookup(addr_t where) { while(true); return 0; }
|
||||
void Flush() { while(true); }
|
||||
void SwitchDirectory(addr_t dir) { while(true); }
|
||||
addr_t CreateAddressSpace() { while(true); return 0; }
|
||||
addr_t SwitchAddressSpace(addr_t addrspace) { while(true); return 0; }
|
||||
addr_t SwitchDirectory(addr_t dir) { while(true); return 0; }
|
||||
addr_t CreateDirectory() { while(true); return 0; }
|
||||
void MapKernel(addr_t where, addr_t physical) { while(true); }
|
||||
addr_t UnmapKernel(addr_t where) { while(true); return 0; }
|
||||
Table* CreateUserTable(addr_t where, bool maycreate) { while(true); return NULL; }
|
||||
bool MapUser(addr_t where, addr_t physical) { while(true); return false; }
|
||||
addr_t UnmapUser(addr_t where) { while(true); return 0; }
|
||||
bool MapRangeKernel(addr_t where, size_t bytes) { while(true); return false; }
|
||||
void UnmapRangeKernel(addr_t where, size_t bytes) { while(true); }
|
||||
bool MapRangeUser(addr_t where, size_t bytes) { while(true); return false; }
|
||||
void UnmapRangeUser(addr_t where, size_t bytes) { while(true); }
|
||||
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -344,6 +344,12 @@ namespace Sortix
|
|||
// good dozen of pages onwards. Beware that this is only meant to be
|
||||
// a temporary place to put memory.
|
||||
const addr_t tempaddr = 0xFF800000UL;
|
||||
|
||||
#elif defined(PLATFORM_X64)
|
||||
// This isn't supported yet, so just use random values.
|
||||
const addr_t heapLower = 0x80000000UL;
|
||||
const addr_t heapUpper = 0xFF800000UL;
|
||||
const addr_t tempaddr = 0xFF800000UL;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
|
@ -81,6 +81,7 @@ namespace Sortix
|
|||
|
||||
void SysExecute(CPU::InterruptRegisters* R)
|
||||
{
|
||||
#ifdef PLATFORM_X86
|
||||
const char* programname = (const char*) R->ebx;
|
||||
|
||||
size_t programsize = 0;
|
||||
|
@ -96,5 +97,6 @@ namespace Sortix
|
|||
R->eip = entry;
|
||||
R->useresp = 0x80000000UL;
|
||||
R->ebp = 0x80000000UL;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -261,6 +261,11 @@ namespace Sortix
|
|||
// Create a new thread data structure.
|
||||
Thread* thread = new Thread(Process, AllocatedThreadId++, PhysStack, StackLength);
|
||||
|
||||
#ifndef PLATFORM_X86
|
||||
#warning "No threads are available on this arch"
|
||||
while(true);
|
||||
#endif
|
||||
|
||||
#ifdef PLATFORM_X86
|
||||
|
||||
uintptr_t StackPos = 0x80000000UL;
|
||||
|
@ -271,7 +276,6 @@ namespace Sortix
|
|||
VirtualMemory::MapUser(MapTo, PhysStack);
|
||||
size_t* Stack = (size_t*) StackPos;
|
||||
|
||||
#ifdef PLATFORM_X86
|
||||
// Prepare the parameters for the entry function (C calling convention).
|
||||
//Stack[StackLength - 1] = (size_t) 0xFACE; // Parameter2
|
||||
Stack[-1] = (size_t) Parameter2; // Parameter2
|
||||
|
@ -280,12 +284,7 @@ namespace Sortix
|
|||
Stack[-4] = (size_t) 0x0; // Eip
|
||||
thread->_registers.ebp = thread->_registers.useresp = (uint32_t) (StackPos - 4*sizeof(size_t)); // Point to the last word used on the stack.
|
||||
thread->_registers.eip = (uint32_t) Start; // Point to our entry function.
|
||||
#endif
|
||||
|
||||
#else
|
||||
#warning "No threads are available on this arch"
|
||||
while(true);
|
||||
#endif
|
||||
|
||||
// Mark the thread as running, which adds it to the scheduler's linked list.
|
||||
thread->SetState(Thread::State::RUNNABLE);
|
||||
|
@ -293,6 +292,8 @@ namespace Sortix
|
|||
// Avoid side effects by restoring the old address space.
|
||||
VirtualMemory::SwitchAddressSpace(OldAddrSpace);
|
||||
|
||||
#endif
|
||||
|
||||
return thread;
|
||||
}
|
||||
|
||||
|
@ -319,12 +320,16 @@ namespace Sortix
|
|||
|
||||
if ( currentThread != NoopThread && currentThread->GetProcess() && sigintpending )
|
||||
{
|
||||
#ifdef PLATFORM_X86
|
||||
Sound::Mute();
|
||||
const char* programname = "sh";
|
||||
R->ebx = (uint32_t) programname;
|
||||
SysExecute(R);
|
||||
sigintpending = false;
|
||||
Log::Print("^C\n");
|
||||
#else
|
||||
#warning "Sigint is not available on this arch"
|
||||
#endif
|
||||
}
|
||||
|
||||
WakeSleeping(TimePassed);
|
||||
|
|
|
@ -55,8 +55,10 @@ namespace Sortix
|
|||
|
||||
void SysSetFrequency(CPU::InterruptRegisters* R)
|
||||
{
|
||||
#ifdef PLATFORM_X86
|
||||
unsigned frequency = R->ebx;
|
||||
if ( frequency == 0 ) { Mute(); } else { Play(frequency); }
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@ namespace Sortix
|
|||
|
||||
void SysCreateFrame(CPU::InterruptRegisters* R)
|
||||
{
|
||||
#ifdef PLATFORM_X86
|
||||
addr_t page = Page::Get();
|
||||
if ( page == NULL ) { R->eax = 0; return; }
|
||||
|
||||
|
@ -102,10 +103,12 @@ namespace Sortix
|
|||
process->_endcodesection = mapto + 0x1000UL;
|
||||
|
||||
R->eax = mapto;
|
||||
#endif
|
||||
}
|
||||
|
||||
void SysChangeFrame(CPU::InterruptRegisters* R)
|
||||
{
|
||||
#ifdef PLATFORM_X86
|
||||
int fd = (int) R->ebx;
|
||||
|
||||
Process* process = CurrentProcess();
|
||||
|
@ -167,11 +170,13 @@ namespace Sortix
|
|||
|
||||
frame->onscreen = true;
|
||||
currentframe = frame;
|
||||
SetCursor(width, height-1);
|
||||
SetCursor(width, height-1);
|
||||
#endif
|
||||
}
|
||||
|
||||
void SysDeleteFrame(CPU::InterruptRegisters* R)
|
||||
{
|
||||
#ifdef PLATFORM_X86
|
||||
int fd = (int) R->ebx;
|
||||
|
||||
Process* process = CurrentProcess();
|
||||
|
@ -181,6 +186,7 @@ namespace Sortix
|
|||
if ( device == NULL ) { R->eax = -1; return; }
|
||||
if ( !device->Close() ) { R->eax = -1; return; }
|
||||
R->eax = 0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
with Sortix. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
memorymanagement-asm.s
|
||||
Handles memory for the x86 architecture.
|
||||
Handles memory for the x64 architecture.
|
||||
|
||||
******************************************************************************/
|
||||
|
||||
|
@ -80,9 +80,9 @@ FragNext:
|
|||
FragDone:
|
||||
ret
|
||||
|
||||
.globl _ZN6Sortix4Page3GetEv
|
||||
.type _ZN6Sortix4Page3GetEv, @function # namespace Sortix { void Paging::Allocate(); }
|
||||
_ZN6Sortix4Page3GetEv:
|
||||
.globl _ZN6Sortix4Page10GetPrivateEv
|
||||
.type _ZN6Sortix4Page10GetPrivateEv, @function # namespace Sortix { void Paging::Allocate(); }
|
||||
_ZN6Sortix4Page10GetPrivateEv:
|
||||
# Load the front of our linked list.
|
||||
movq _ZN6Sortix4Page15UnallocatedPageE, %rax # Load UnallocPage* Sortix::Page::UnallocatedPage
|
||||
|
||||
|
@ -135,9 +135,9 @@ OutOfMem:
|
|||
movq $0, %rax
|
||||
ret
|
||||
|
||||
.globl _ZN6Sortix4Page3PutEPv
|
||||
.type _ZN6Sortix4Page3PutEPv, @function # namespace Sortix { void Paging::Free(void* Page); }
|
||||
_ZN6Sortix4Page3PutEPv:
|
||||
.globl _ZN6Sortix4Page10PutPrivateEm
|
||||
.type _ZN6Sortix4Page10PutPrivateEm, @function # namespace Sortix { void Paging::Free(void* Page); }
|
||||
_ZN6Sortix4Page10PutPrivateEm:
|
||||
movq _ZN6Sortix4Page15UnallocatedPageE, %rax # Load UnallocPage* Sortix::Page::UnallocatedPage
|
||||
|
||||
# Disable virtual memory
|
||||
|
|
Loading…
Reference in a new issue