mirror of https://gitlab.com/nakst/essence
better support for running on real hardware
This commit is contained in:
parent
34f86b3f91
commit
0319f08a1a
|
@ -5,6 +5,15 @@
|
||||||
#define K_PAGE_SIZE (4096)
|
#define K_PAGE_SIZE (4096)
|
||||||
#define K_PAGE_BITS (12)
|
#define K_PAGE_BITS (12)
|
||||||
|
|
||||||
|
typedef struct VideoModeInformation {
|
||||||
|
uint8_t valid : 1, edidValid : 1;
|
||||||
|
uint8_t bitsPerPixel;
|
||||||
|
uint16_t widthPixels, heightPixels;
|
||||||
|
uint16_t bytesPerScanlineLinear;
|
||||||
|
uint64_t bufferPhysical;
|
||||||
|
uint8_t edid[128];
|
||||||
|
} VideoModeInformation;
|
||||||
|
|
||||||
typedef struct ElfHeader {
|
typedef struct ElfHeader {
|
||||||
uint32_t magicNumber; // 0x7F followed by 'ELF'
|
uint32_t magicNumber; // 0x7F followed by 'ELF'
|
||||||
uint8_t bits; // 1 = 32 bit, 2 = 64 bit
|
uint8_t bits; // 1 = 32 bit, 2 = 64 bit
|
||||||
|
@ -79,13 +88,28 @@ void ZeroMemory(void *pointer, uint64_t size) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Error(WCHAR *message) {
|
void Print(WCHAR *message) {
|
||||||
uefi_call_wrapper(systemTable->ConOut->OutputString, 2, systemTable->ConOut, message);
|
uefi_call_wrapper(systemTable->ConOut->OutputString, 2, systemTable->ConOut, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Error(WCHAR *message) {
|
||||||
|
Print(message);
|
||||||
while (1);
|
while (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PrintHex(uint64_t value) {
|
||||||
|
const WCHAR *hexChars = L"0123456789ABCDEF";
|
||||||
|
|
||||||
|
for (uintptr_t i = 0; i < 16; i++) {
|
||||||
|
WCHAR b[2] = { hexChars[(value >> (60 - i * 4)) & 0xF], 0 };
|
||||||
|
Print((WCHAR *) b);
|
||||||
|
}
|
||||||
|
|
||||||
|
Print(L", ");
|
||||||
|
}
|
||||||
|
|
||||||
EFI_STATUS EFIAPI efi_main(EFI_HANDLE imageHandle, EFI_SYSTEM_TABLE *_systemTable) {
|
EFI_STATUS EFIAPI efi_main(EFI_HANDLE imageHandle, EFI_SYSTEM_TABLE *_systemTable) {
|
||||||
UINTN mapKey;
|
UINTN mapKey = 0;
|
||||||
systemTable = _systemTable;
|
systemTable = _systemTable;
|
||||||
uint32_t *framebuffer, horizontalResolution, verticalResolution, pixelsPerScanline;
|
uint32_t *framebuffer, horizontalResolution, verticalResolution, pixelsPerScanline;
|
||||||
ElfHeader *header;
|
ElfHeader *header;
|
||||||
|
@ -95,12 +119,14 @@ EFI_STATUS EFIAPI efi_main(EFI_HANDLE imageHandle, EFI_SYSTEM_TABLE *_systemTabl
|
||||||
EFI_PHYSICAL_ADDRESS address = 0x100000;
|
EFI_PHYSICAL_ADDRESS address = 0x100000;
|
||||||
|
|
||||||
if (EFI_SUCCESS != uefi_call_wrapper(systemTable->BootServices->AllocatePages, 4, AllocateAddress, EfiLoaderData, 0x200, &address)) {
|
if (EFI_SUCCESS != uefi_call_wrapper(systemTable->BootServices->AllocatePages, 4, AllocateAddress, EfiLoaderData, 0x200, &address)) {
|
||||||
Error(L"Error: Could not map 0x100000 -> 0x180000.\n");
|
Error(L"Error: Could not allocate 1MB->3MB.\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the RSDP.
|
// Find the RSDP.
|
||||||
{
|
{
|
||||||
|
uint8_t foundRSDP = 0;
|
||||||
|
|
||||||
for (uintptr_t i = 0; i < systemTable->NumberOfTableEntries; i++) {
|
for (uintptr_t i = 0; i < systemTable->NumberOfTableEntries; i++) {
|
||||||
EFI_CONFIGURATION_TABLE *entry = systemTable->ConfigurationTable + i;
|
EFI_CONFIGURATION_TABLE *entry = systemTable->ConfigurationTable + i;
|
||||||
if (entry->VendorGuid.Data1 == 0x8868E871 && entry->VendorGuid.Data2 == 0xE4F1 && entry->VendorGuid.Data3 == 0x11D3
|
if (entry->VendorGuid.Data1 == 0x8868E871 && entry->VendorGuid.Data2 == 0xE4F1 && entry->VendorGuid.Data3 == 0x11D3
|
||||||
|
@ -108,9 +134,14 @@ EFI_STATUS EFIAPI efi_main(EFI_HANDLE imageHandle, EFI_SYSTEM_TABLE *_systemTabl
|
||||||
&& entry->VendorGuid.Data4[3] == 0x80 && entry->VendorGuid.Data4[4] == 0xC7 && entry->VendorGuid.Data4[5] == 0x3C
|
&& entry->VendorGuid.Data4[3] == 0x80 && entry->VendorGuid.Data4[4] == 0xC7 && entry->VendorGuid.Data4[5] == 0x3C
|
||||||
&& entry->VendorGuid.Data4[6] == 0x88 && entry->VendorGuid.Data4[7] == 0x81) {
|
&& entry->VendorGuid.Data4[6] == 0x88 && entry->VendorGuid.Data4[7] == 0x81) {
|
||||||
*((uint64_t *) 0x107FE8) = (uint64_t) entry->VendorTable;
|
*((uint64_t *) 0x107FE8) = (uint64_t) entry->VendorTable;
|
||||||
// Print(L"The RSDP can be found at 0x%x.\n", entry->VendorTable);
|
foundRSDP = 1;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!foundRSDP) {
|
||||||
|
Error(L"Error: Could not find the RSDP.\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read the kernel, IID and loader files.
|
// Read the kernel, IID and loader files.
|
||||||
|
@ -125,13 +156,15 @@ EFI_STATUS EFIAPI efi_main(EFI_HANDLE imageHandle, EFI_SYSTEM_TABLE *_systemTabl
|
||||||
|
|
||||||
UINTN size;
|
UINTN size;
|
||||||
|
|
||||||
if (EFI_SUCCESS != uefi_call_wrapper(systemTable->BootServices->OpenProtocol, 6, imageHandle, &loadedImageProtocolGUID, (void **) &loadedImageProtocol, imageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL)) {
|
if (EFI_SUCCESS != uefi_call_wrapper(systemTable->BootServices->OpenProtocol, 6, imageHandle, &loadedImageProtocolGUID,
|
||||||
|
(void **) &loadedImageProtocol, imageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL)) {
|
||||||
Error(L"Error: Could not open protocol 1.\n");
|
Error(L"Error: Could not open protocol 1.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
EFI_HANDLE deviceHandle = loadedImageProtocol->DeviceHandle;
|
EFI_HANDLE deviceHandle = loadedImageProtocol->DeviceHandle;
|
||||||
|
|
||||||
if (EFI_SUCCESS != uefi_call_wrapper(systemTable->BootServices->OpenProtocol, 6, deviceHandle, &simpleFilesystemProtocolGUID, (void **) &simpleFilesystemProtocol, imageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL)) {
|
if (EFI_SUCCESS != uefi_call_wrapper(systemTable->BootServices->OpenProtocol, 6, deviceHandle, &simpleFilesystemProtocolGUID,
|
||||||
|
(void **) &simpleFilesystemProtocol, imageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL)) {
|
||||||
Error(L"Error: Could not open procotol 2.\n");
|
Error(L"Error: Could not open procotol 2.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +185,7 @@ EFI_STATUS EFIAPI efi_main(EFI_HANDLE imageHandle, EFI_SYSTEM_TABLE *_systemTabl
|
||||||
// Print(L"Kernel size: %d bytes\n", size);
|
// Print(L"Kernel size: %d bytes\n", size);
|
||||||
|
|
||||||
if (size == KERNEL_BUFFER_SIZE) {
|
if (size == KERNEL_BUFFER_SIZE) {
|
||||||
Error(L"Kernel too large to fit into buffer.\n");
|
Error(L"Error: Kernel too large to fit into buffer.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EFI_SUCCESS != uefi_call_wrapper(filesystemRoot->Open, 5, filesystemRoot, &iidFile, L"esiid.dat", EFI_FILE_MODE_READ, 0)) {
|
if (EFI_SUCCESS != uefi_call_wrapper(filesystemRoot->Open, 5, filesystemRoot, &iidFile, L"esiid.dat", EFI_FILE_MODE_READ, 0)) {
|
||||||
|
@ -178,6 +211,7 @@ EFI_STATUS EFIAPI efi_main(EFI_HANDLE imageHandle, EFI_SYSTEM_TABLE *_systemTabl
|
||||||
|
|
||||||
// Get the graphics mode information.
|
// Get the graphics mode information.
|
||||||
// TODO Mode picking.
|
// TODO Mode picking.
|
||||||
|
// TODO Get EDID information, if available.
|
||||||
{
|
{
|
||||||
EFI_GRAPHICS_OUTPUT_PROTOCOL *graphicsOutputProtocol;
|
EFI_GRAPHICS_OUTPUT_PROTOCOL *graphicsOutputProtocol;
|
||||||
EFI_GUID graphicsOutputProtocolGUID = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
|
EFI_GUID graphicsOutputProtocolGUID = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
|
||||||
|
@ -197,7 +231,8 @@ EFI_STATUS EFIAPI efi_main(EFI_HANDLE imageHandle, EFI_SYSTEM_TABLE *_systemTabl
|
||||||
UINTN descriptorSize, size = MEMORY_MAP_BUFFER_SIZE;
|
UINTN descriptorSize, size = MEMORY_MAP_BUFFER_SIZE;
|
||||||
UINT32 descriptorVersion;
|
UINT32 descriptorVersion;
|
||||||
|
|
||||||
if (EFI_SUCCESS != uefi_call_wrapper(systemTable->BootServices->GetMemoryMap, 5, &size, (EFI_MEMORY_DESCRIPTOR *) memoryMapBuffer, &mapKey, &descriptorSize, &descriptorVersion)) {
|
if (EFI_SUCCESS != uefi_call_wrapper(systemTable->BootServices->GetMemoryMap, 5, &size,
|
||||||
|
(EFI_MEMORY_DESCRIPTOR *) memoryMapBuffer, &mapKey, &descriptorSize, &descriptorVersion)) {
|
||||||
Error(L"Error: Could not get memory map.\n");
|
Error(L"Error: Could not get memory map.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,14 +263,14 @@ EFI_STATUS EFIAPI efi_main(EFI_HANDLE imageHandle, EFI_SYSTEM_TABLE *_systemTabl
|
||||||
uint64_t *paging = (uint64_t *) 0x140000;
|
uint64_t *paging = (uint64_t *) 0x140000;
|
||||||
ZeroMemory(paging, 0x5000);
|
ZeroMemory(paging, 0x5000);
|
||||||
|
|
||||||
paging[0x1FE] = 0x140003;
|
paging[0x1FE] = 0x140003; // Recursive
|
||||||
paging[0x000] = 0x141003;
|
paging[0x000] = 0x141003; // L4
|
||||||
paging[0x200] = 0x142003;
|
paging[0x200] = 0x142003; // L3
|
||||||
paging[0x400] = 0x143003;
|
paging[0x400] = 0x143003; // L2
|
||||||
paging[0x401] = 0x144003;
|
paging[0x401] = 0x144003;
|
||||||
|
|
||||||
for (uintptr_t i = 0; i < 0x400; i++) {
|
for (uintptr_t i = 0; i < 0x400; i++) {
|
||||||
paging[0x600 + i] = (i * 0x1000) | 3;
|
paging[0x600 + i] = (i * 0x1000) | 3; // L1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,17 +284,16 @@ EFI_STATUS EFIAPI efi_main(EFI_HANDLE imageHandle, EFI_SYSTEM_TABLE *_systemTabl
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy the graphics information across.
|
// Copy the graphics information across.
|
||||||
// TODO.
|
|
||||||
#if 0
|
|
||||||
{
|
{
|
||||||
struct VESAVideoModeInformation *destination = (struct VESAVideoModeInformation *) (0x107000);
|
VideoModeInformation *destination = (VideoModeInformation *) (0x107000);
|
||||||
destination->widthPixels = horizontalResolution;
|
destination->widthPixels = horizontalResolution;
|
||||||
destination->heightPixels = verticalResolution;
|
destination->heightPixels = verticalResolution;
|
||||||
destination->bufferPhysical = (uintptr_t) framebuffer; // TODO 64-bit framebuffers.
|
destination->bufferPhysical = (uint64_t) framebuffer;
|
||||||
destination->bytesPerScanlineLinear = pixelsPerScanline * 4;
|
destination->bytesPerScanlineLinear = pixelsPerScanline * 4;
|
||||||
destination->bitsPerPixel = 32;
|
destination->bitsPerPixel = 32;
|
||||||
|
destination->valid = 1;
|
||||||
|
destination->edidValid = 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// Allocate and map memory for the kernel.
|
// Allocate and map memory for the kernel.
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,7 +7,6 @@ vbe_init:
|
||||||
jmp vbe_bad
|
jmp vbe_bad
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
|
|
||||||
; Get EDID information.
|
; Get EDID information.
|
||||||
mov ax,0x4F15
|
mov ax,0x4F15
|
||||||
mov bl,1
|
mov bl,1
|
||||||
|
|
|
@ -787,11 +787,11 @@ static void DeviceAttach(KDevice *parentDevice) {
|
||||||
ACPIInitialise2();
|
ACPIInitialise2();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
KDeviceAttachByName(acpi.computer, "PCI");
|
|
||||||
|
|
||||||
if (!acpi.vgaControllerUnavailable) {
|
if (!acpi.vgaControllerUnavailable) {
|
||||||
KDeviceAttachByName(acpi.computer, "SVGA");
|
KDeviceAttachByName(acpi.computer, "SVGA");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KDeviceAttachByName(acpi.computer, "PCI");
|
||||||
}
|
}
|
||||||
|
|
||||||
KDriver driverACPI = {
|
KDriver driverACPI = {
|
||||||
|
|
|
@ -103,12 +103,17 @@ void KRegisterGraphicsTarget(KGraphicsTarget *target) {
|
||||||
|
|
||||||
graphics.frameBuffer.Resize(graphics.width, graphics.height);
|
graphics.frameBuffer.Resize(graphics.width, graphics.height);
|
||||||
|
|
||||||
|
#ifdef START_DEBUG_OUTPUT
|
||||||
|
StartDebugOutput();
|
||||||
|
EsPrint("Hello\n");
|
||||||
|
#else
|
||||||
windowManager.Initialise();
|
windowManager.Initialise();
|
||||||
|
|
||||||
EsMessage m;
|
EsMessage m;
|
||||||
EsMemoryZero(&m, sizeof(EsMessage));
|
EsMemoryZero(&m, sizeof(EsMessage));
|
||||||
m.type = ES_MSG_SET_SCREEN_RESOLUTION;
|
m.type = ES_MSG_SET_SCREEN_RESOLUTION;
|
||||||
desktopProcess->messageQueue.SendMessage(nullptr, &m);
|
desktopProcess->messageQueue.SendMessage(nullptr, &m);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Surface::Resize(size_t newResX, size_t newResY, uint32_t clearColor, bool copyOldBits) {
|
bool Surface::Resize(size_t newResX, size_t newResY, uint32_t clearColor, bool copyOldBits) {
|
||||||
|
@ -580,6 +585,11 @@ void GraphicsDebugPutBlock32(uintptr_t x, uintptr_t y, bool toggle,
|
||||||
void GraphicsDebugClearScreen32(unsigned screenWidth, unsigned screenHeight, unsigned stride, volatile uint8_t *linearBuffer) {
|
void GraphicsDebugClearScreen32(unsigned screenWidth, unsigned screenHeight, unsigned stride, volatile uint8_t *linearBuffer) {
|
||||||
for (uintptr_t i = 0; i < screenHeight; i++) {
|
for (uintptr_t i = 0; i < screenHeight; i++) {
|
||||||
for (uintptr_t j = 0; j < screenWidth * 4; j += 4) {
|
for (uintptr_t j = 0; j < screenWidth * 4; j += 4) {
|
||||||
|
linearBuffer[i * stride + j + 2] = 0x18;
|
||||||
|
linearBuffer[i * stride + j + 1] = 0x7E;
|
||||||
|
linearBuffer[i * stride + j + 0] = 0xCF;
|
||||||
|
|
||||||
|
#if 0
|
||||||
if (graphics.debuggerActive) {
|
if (graphics.debuggerActive) {
|
||||||
linearBuffer[i * stride + j + 2] = 0x18;
|
linearBuffer[i * stride + j + 2] = 0x18;
|
||||||
linearBuffer[i * stride + j + 1] = 0x7E;
|
linearBuffer[i * stride + j + 1] = 0x7E;
|
||||||
|
@ -589,6 +599,7 @@ void GraphicsDebugClearScreen32(unsigned screenWidth, unsigned screenHeight, uns
|
||||||
linearBuffer[i * stride + j + 1] >>= 1;
|
linearBuffer[i * stride + j + 1] >>= 1;
|
||||||
linearBuffer[i * stride + j + 0] >>= 1;
|
linearBuffer[i * stride + j + 0] >>= 1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,6 +104,8 @@ InterruptContext *ArchInitialiseThread(uintptr_t kernelStack, uintptr_t kernelSt
|
||||||
uintptr_t startAddress, uintptr_t argument1, uintptr_t argument2,
|
uintptr_t startAddress, uintptr_t argument1, uintptr_t argument2,
|
||||||
bool userland, uintptr_t stack, uintptr_t userStackSize);
|
bool userland, uintptr_t stack, uintptr_t userStackSize);
|
||||||
|
|
||||||
|
void StartDebugOutput();
|
||||||
|
|
||||||
uint64_t timeStampTicksPerMs;
|
uint64_t timeStampTicksPerMs;
|
||||||
|
|
||||||
EsUniqueIdentifier installationID; // The identifier of this OS installation, given to us by the bootloader.
|
EsUniqueIdentifier installationID; // The identifier of this OS installation, given to us by the bootloader.
|
||||||
|
|
|
@ -22,13 +22,9 @@ void DebugWriteCharacter(uintptr_t character);
|
||||||
bool printToDebugger = false;
|
bool printToDebugger = false;
|
||||||
uintptr_t terminalPosition = 80;
|
uintptr_t terminalPosition = 80;
|
||||||
|
|
||||||
#define EARLY_DEBUGGING
|
#define KERNEL_LOG_SIZE (262144)
|
||||||
// #define VGA_TEXT_MODE
|
char kernelLog[KERNEL_LOG_SIZE];
|
||||||
|
|
||||||
#ifdef EARLY_DEBUGGING
|
|
||||||
char kernelLog[262144];
|
|
||||||
uintptr_t kernelLogPosition;
|
uintptr_t kernelLogPosition;
|
||||||
#endif
|
|
||||||
|
|
||||||
static void TerminalCallback(int character, void *) {
|
static void TerminalCallback(int character, void *) {
|
||||||
if (!character) return;
|
if (!character) return;
|
||||||
|
@ -36,13 +32,11 @@ static void TerminalCallback(int character, void *) {
|
||||||
KSpinlockAcquire(&terminalLock);
|
KSpinlockAcquire(&terminalLock);
|
||||||
EsDefer(KSpinlockRelease(&terminalLock));
|
EsDefer(KSpinlockRelease(&terminalLock));
|
||||||
|
|
||||||
#ifdef EARLY_DEBUGGING
|
if (sizeof(kernelLog)) {
|
||||||
{
|
|
||||||
kernelLog[kernelLogPosition] = character;
|
kernelLog[kernelLogPosition] = character;
|
||||||
kernelLogPosition++;
|
kernelLogPosition++;
|
||||||
if (kernelLogPosition == sizeof(kernelLog)) kernelLogPosition = 0;
|
if (kernelLogPosition == sizeof(kernelLog)) kernelLogPosition = 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef VGA_TEXT_MODE
|
#ifdef VGA_TEXT_MODE
|
||||||
{
|
{
|
||||||
|
@ -139,7 +133,7 @@ void DebugWriteCharacter(uintptr_t character) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartDebugOutput() {
|
void StartDebugOutput() {
|
||||||
if (graphics.target && graphics.target->debugClearScreen && graphics.target->debugPutBlock) {
|
if (graphics.target && graphics.target->debugClearScreen && graphics.target->debugPutBlock && !printToDebugger) {
|
||||||
debugRows = (graphics.height - 1) / VGA_FONT_HEIGHT;
|
debugRows = (graphics.height - 1) / VGA_FONT_HEIGHT;
|
||||||
debugColumns = (graphics.width - 1) / VGA_FONT_WIDTH - 2;
|
debugColumns = (graphics.width - 1) / VGA_FONT_WIDTH - 2;
|
||||||
debugCurrentRow = debugCurrentColumn = 0;
|
debugCurrentRow = debugCurrentColumn = 0;
|
||||||
|
@ -156,6 +150,7 @@ void KDebugKeyPressed() {
|
||||||
KernelPanic("Debug key pressed.\n");
|
KernelPanic("Debug key pressed.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef POST_PANIC_DEBUGGING
|
||||||
uintptr_t DebugReadNumber() {
|
uintptr_t DebugReadNumber() {
|
||||||
uintptr_t value = 0;
|
uintptr_t value = 0;
|
||||||
|
|
||||||
|
@ -188,6 +183,7 @@ uintptr_t DebugReadNumber() {
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void KernelPanic(const char *format, ...) {
|
void KernelPanic(const char *format, ...) {
|
||||||
ProcessorDisableInterrupts();
|
ProcessorDisableInterrupts();
|
||||||
|
@ -201,7 +197,7 @@ void KernelPanic(const char *format, ...) {
|
||||||
DriversDumpState();
|
DriversDumpState();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!printToDebugger) StartDebugOutput();
|
StartDebugOutput();
|
||||||
|
|
||||||
EsPrint("\n--- System Error ---\n>> ");
|
EsPrint("\n--- System Error ---\n>> ");
|
||||||
|
|
||||||
|
@ -251,7 +247,7 @@ void KernelPanic(const char *format, ...) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef EARLY_DEBUGGING
|
#ifdef POST_PANIC_DEBUGGING
|
||||||
uintptr_t kernelLogEnd = kernelLogPosition;
|
uintptr_t kernelLogEnd = kernelLogPosition;
|
||||||
EsPrint("Press 'D' to enter debugger.\n");
|
EsPrint("Press 'D' to enter debugger.\n");
|
||||||
while (KWaitKey() != ES_SCANCODE_D);
|
while (KWaitKey() != ES_SCANCODE_D);
|
||||||
|
@ -279,8 +275,6 @@ void KernelPanic(const char *format, ...) {
|
||||||
uintptr_t position = 0, nextPosition = 0;
|
uintptr_t position = 0, nextPosition = 0;
|
||||||
uintptr_t x = 0, y = 0;
|
uintptr_t x = 0, y = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef VGA_TEXT_MODE
|
#ifdef VGA_TEXT_MODE
|
||||||
for (uintptr_t i = 0; i < 80 * 25; i++) {
|
for (uintptr_t i = 0; i < 80 * 25; i++) {
|
||||||
TERMINAL_ADDRESS[i] = 0x0700;
|
TERMINAL_ADDRESS[i] = 0x0700;
|
||||||
|
|
|
@ -286,6 +286,8 @@ Option options[] = {
|
||||||
{ "Flag.CHECK_FOR_NOT_RESPONDING", OPTION_TYPE_BOOL, { .b = true } },
|
{ "Flag.CHECK_FOR_NOT_RESPONDING", OPTION_TYPE_BOOL, { .b = true } },
|
||||||
{ "Flag._ALWAYS_USE_VBE", OPTION_TYPE_BOOL, { .b = false } },
|
{ "Flag._ALWAYS_USE_VBE", OPTION_TYPE_BOOL, { .b = false } },
|
||||||
{ "Flag.COM_OUTPUT", OPTION_TYPE_BOOL, { .b = true } },
|
{ "Flag.COM_OUTPUT", OPTION_TYPE_BOOL, { .b = true } },
|
||||||
|
{ "Flag.POST_PANIC_DEBUGGING", OPTION_TYPE_BOOL, { .b = false } },
|
||||||
|
{ "Flag.START_DEBUG_OUTPUT", OPTION_TYPE_BOOL, { .b = false } },
|
||||||
{ "Dependency.ACPICA", OPTION_TYPE_BOOL, { .b = true } },
|
{ "Dependency.ACPICA", OPTION_TYPE_BOOL, { .b = true } },
|
||||||
{ "Dependency.stb_image", OPTION_TYPE_BOOL, { .b = true } },
|
{ "Dependency.stb_image", OPTION_TYPE_BOOL, { .b = true } },
|
||||||
{ "Dependency.stb_image_write", OPTION_TYPE_BOOL, { .b = true } },
|
{ "Dependency.stb_image_write", OPTION_TYPE_BOOL, { .b = true } },
|
||||||
|
@ -308,6 +310,7 @@ Option options[] = {
|
||||||
{ "Emulator.VBoxEFI", OPTION_TYPE_BOOL, { .b = false } },
|
{ "Emulator.VBoxEFI", OPTION_TYPE_BOOL, { .b = false } },
|
||||||
{ "Emulator.QemuEFI", OPTION_TYPE_BOOL, { .b = false } },
|
{ "Emulator.QemuEFI", OPTION_TYPE_BOOL, { .b = false } },
|
||||||
{ "BuildCore.Verbose", OPTION_TYPE_BOOL, { .b = false } },
|
{ "BuildCore.Verbose", OPTION_TYPE_BOOL, { .b = false } },
|
||||||
|
{ "BuildCore.DeletePOSIXBeforeImport", OPTION_TYPE_BOOL, { .b = false } },
|
||||||
{ "General.first_application", OPTION_TYPE_STRING, { .s = NULL } },
|
{ "General.first_application", OPTION_TYPE_STRING, { .s = NULL } },
|
||||||
{ "General.wallpaper", OPTION_TYPE_STRING, { .s = NULL } },
|
{ "General.wallpaper", OPTION_TYPE_STRING, { .s = NULL } },
|
||||||
{ "General.installation_state", OPTION_TYPE_STRING, { .s = "0" } },
|
{ "General.installation_state", OPTION_TYPE_STRING, { .s = "0" } },
|
||||||
|
|
|
@ -156,7 +156,7 @@ char kernelAssemblyFlags[4096] = " -felf64 -Fdwarf ";
|
||||||
|
|
||||||
bool verbose;
|
bool verbose;
|
||||||
bool useColoredOutput;
|
bool useColoredOutput;
|
||||||
bool forEmulator, bootUseVBE;
|
bool forEmulator, bootUseVBE, deletePOSIXBeforeImport;
|
||||||
bool systemBuild;
|
bool systemBuild;
|
||||||
bool convertFonts = true;
|
bool convertFonts = true;
|
||||||
EsINIState *fontLines;
|
EsINIState *fontLines;
|
||||||
|
@ -1169,6 +1169,12 @@ void Install(const char *driveFile, uint64_t partitionSize, const char *partitio
|
||||||
_partitionOffset = 1048576;
|
_partitionOffset = 1048576;
|
||||||
Format(partitionSize - _partitionOffset, partitionLabel, installationIdentifier, kernel, kernelBytes);
|
Format(partitionSize - _partitionOffset, partitionLabel, installationIdentifier, kernel, kernelBytes);
|
||||||
|
|
||||||
|
#ifndef OS_ESSENCE
|
||||||
|
if (deletePOSIXBeforeImport) {
|
||||||
|
system("rm -r root/Applications/POSIX");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
Log("Copying files to the drive... ");
|
Log("Copying files to the drive... ");
|
||||||
|
|
||||||
ImportNode root = {};
|
ImportNode root = {};
|
||||||
|
@ -1302,6 +1308,8 @@ int main(int argc, char **argv) {
|
||||||
bootUseVBE = !!atoi(s.value);
|
bootUseVBE = !!atoi(s.value);
|
||||||
} else if (0 == strcmp(s.key, "Flag.COM_OUTPUT") && atoi(s.value)) {
|
} else if (0 == strcmp(s.key, "Flag.COM_OUTPUT") && atoi(s.value)) {
|
||||||
strcat(kernelAssemblyFlags, " -DCOM_OUTPUT ");
|
strcat(kernelAssemblyFlags, " -DCOM_OUTPUT ");
|
||||||
|
} else if (0 == strcmp(s.key, "BuildCore.DeletePOSIXBeforeImport")) {
|
||||||
|
deletePOSIXBeforeImport = !!atoi(s.value);
|
||||||
} else if (0 == memcmp(s.key, "General.", 8)) {
|
} else if (0 == memcmp(s.key, "General.", 8)) {
|
||||||
EsINIState s2 = s;
|
EsINIState s2 = s;
|
||||||
s2.key += 8, s2.keyBytes -= 8;
|
s2.key += 8, s2.keyBytes -= 8;
|
||||||
|
|
|
@ -16,7 +16,7 @@ LINK="clang -target x86_64-unknown-windows -nostdlib -Wl,-entry:efi_main -Wl,-su
|
||||||
$CC -o bin/uefi.o boot/x86/uefi.c
|
$CC -o bin/uefi.o boot/x86/uefi.c
|
||||||
$LINK -o bin/uefi bin/uefi.o
|
$LINK -o bin/uefi bin/uefi.o
|
||||||
|
|
||||||
mkdir mount
|
mkdir -p mount
|
||||||
sudo losetup --offset `fdisk -l bin/uefi_drive | grep 'EFI System' | awk '{print 512*$2}'` --sizelimit `fdisk -l bin/uefi_drive | grep 'EFI System' | awk '{print 512*$4}'` /dev/loop0 bin/uefi_drive
|
sudo losetup --offset `fdisk -l bin/uefi_drive | grep 'EFI System' | awk '{print 512*$2}'` --sizelimit `fdisk -l bin/uefi_drive | grep 'EFI System' | awk '{print 512*$4}'` /dev/loop0 bin/uefi_drive
|
||||||
# sudo mkfs.fat /dev/loop0
|
# sudo mkfs.fat /dev/loop0
|
||||||
sudo mount /dev/loop0 mount
|
sudo mount /dev/loop0 mount
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
# Run as root.
|
||||||
|
# Pass device file of ESP as first argument.
|
||||||
|
# Pass device file of EsFS partition as second argument.
|
||||||
|
|
||||||
|
set -e
|
||||||
|
mkdir -p mount
|
||||||
|
mount $1 mount
|
||||||
|
mkdir -p mount/EFI/BOOT
|
||||||
|
cp bin/uefi mount/EFI/BOOT/BOOTX64.EFI
|
||||||
|
cp bin/Kernel.esx mount/eskernel.esx
|
||||||
|
cp bin/uefi_loader mount/esloader.bin
|
||||||
|
cp bin/iid.dat mount/esiid.dat
|
||||||
|
umount $1
|
||||||
|
rmdir mount
|
||||||
|
|
||||||
|
SOURCE_OFFSET=`fdisk -l bin/drive | grep 'Linux' | awk '{print $3}'`
|
||||||
|
SOURCE_COUNT=`fdisk -l bin/drive | grep 'Linux' | awk '{print $5}'`
|
||||||
|
DESTINATION_COUNT=`blockdev --getsz $2`
|
||||||
|
|
||||||
|
if [ "$SOURCE_COUNT" -gt "$DESTINATION_COUNT" ]; then
|
||||||
|
echo Please set Emulator.PrimaryDriveMB lower than $DESTINATION_COUNT.
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
dd if=bin/drive of=$2 bs=512 count=$SOURCE_COUNT skip=$SOURCE_OFFSET conv=notrunc
|
Loading…
Reference in New Issue