Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e9450da
Working on a port to x86_64, switching from GRUB to Limine
maxdev1 Mar 20, 2025
edd42a3
Fix routines
maxdev1 Mar 20, 2025
42844ad
Fix some address types
maxdev1 Mar 21, 2025
5729a65
Fix many more things
maxdev1 Mar 21, 2025
8a8229b
Fix relocations, task PD setup & constants
maxdev1 Mar 22, 2025
e65c98e
Fix relocations
maxdev1 Mar 22, 2025
8ffbb9d
Fix syscalls (TODO: use sysenter)
maxdev1 Mar 23, 2025
9326649
Fix more things
maxdev1 Mar 23, 2025
e6bf8cc
Clean up & reduce diff
maxdev1 Mar 23, 2025
09b030d
Clean up
maxdev1 Mar 23, 2025
b8d1b5e
Add stack alignment to CRT0 to ensure it in programs after kernel ent…
maxdev1 Mar 23, 2025
24c8954
Stack alignment issues...
maxdev1 Mar 23, 2025
6c19420
Fix relocations
maxdev1 Mar 23, 2025
20a209b
Fix address
maxdev1 Mar 23, 2025
6690a89
Remove VBE driver, add efifbdriver that simply passes on EFI framebuf…
maxdev1 Mar 23, 2025
f828287
Clean up
maxdev1 Mar 23, 2025
4f50687
Remove log
maxdev1 Mar 24, 2025
2cc9f00
Almost fixed 64 bit AP trampoline code
maxdev1 Apr 14, 2025
688978a
Add own 64 bit data segment?
maxdev1 Apr 14, 2025
18a4902
Fixes for AP startup sequence
maxdev1 Oct 21, 2025
418c676
Set EFER.NXE, since Limine sets up an initial PD with NX bits set
maxdev1 Oct 21, 2025
a6f48e2
Ensure long page mask
maxdev1 Oct 21, 2025
8d7856f
Yeah yeah
maxdev1 Oct 21, 2025
7aa4c05
Remove log
maxdev1 Oct 21, 2025
6b0f13e
Clean up; cpuid is always supported on x86_64 & RSP/SS always pushed …
maxdev1 Oct 21, 2025
cdd5f39
Remove "shared" folder structure & join in kernel directory
maxdev1 Oct 21, 2025
93664a1
Cleanup
maxdev1 Oct 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ documentation/out/*
target/iso/boot/kernel
target/iso/boot/loader
target/iso/boot/ramdisk
target/iso/boot/limine/limine-*.sys
target/iso/boot/limine/limine-*.bin
target/limine-*/*
target/limine-*.tar.gz

node_modules

sysroot/system/include
sysroot/system/lib/*
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ VMSVGA graphics adapter enabled for better performance.
Afterwards, the `target` folder will contain the bootable ISO image.

## Features
* x86-based micro-kernel
* x86_64-based micro-kernel
* SMP multi-processor support
* Comprehensive kernel interaction library (libapi)
* Own C standard library (libc)
Expand Down
2 changes: 1 addition & 1 deletion applications/ahcidriver/src/ahcidriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ bool ahciDriverIdentifyController()
devices[i].subclassCode == PCI_01_SUBCLASS_SATA &&
devices[i].progIf == PCI_01_06_PROGIF_AHCI)
{
uint32_t bar;
g_address bar;
if(!pciDriverReadBAR(devices[i].deviceAddress, 5, &bar))
{
klog("Failed to read BAR5 from PCI device %x", devices[i].deviceAddress);
Expand Down
4 changes: 2 additions & 2 deletions applications/devicemanager/src/manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ void _deviceManagerCheckPciDevices()
}
else
{
klog("starting VBE driver");
g_spawn("/applications/vbedriver.bin", "", "", G_SECURITY_LEVEL_DRIVER);
klog("starting EFI FB driver");
g_spawn("/applications/efifbdriver.bin", "", "", G_SECURITY_LEVEL_DRIVER);
}
}

Expand Down
2 changes: 1 addition & 1 deletion applications/vbedriver/build.sh → applications/efifbdriver/build.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fi
. "$ROOT/ghost.sh"

# Build configuration
ARTIFACT_NAME="vbedriver.bin"
ARTIFACT_NAME="efifbdriver.bin"
LDFLAGS="-ldevice"

# Include application build tasks
Expand Down
98 changes: 98 additions & 0 deletions applications/efifbdriver/src/efifbdriver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Ghost, a micro-kernel based operating system for the x86 architecture *
* Copyright (C) 2015, Max Schlüssel <[email protected]> *
* *
* This program 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. *
* *
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#include "efifbdriver.hpp"

#include <libdevice/manager.hpp>
#include <ghost.h>

#include <stdint.h>
#include <string.h>
#include <stdio.h>

g_device_id deviceId;

int main()
{
g_task_register_name("efifbdriver");

if(!deviceManagerRegisterDevice(G_DEVICE_TYPE_VIDEO, g_get_tid(), &deviceId))
{
klog("failed to register device with device manager");
return -1;
}
klog("registered EFI FB device %i", deviceId);

efifbDriverReceiveMessages();
return 0;
}

void efifbDriverReceiveMessages()
{
size_t buflen = sizeof(g_message_header) + 1024;
uint8_t buf[buflen];

for(;;)
{
auto status = g_receive_message(buf, buflen);
if(status != G_MESSAGE_RECEIVE_STATUS_SUCCESSFUL)
{
continue;
}

g_message_header* header = (g_message_header*) buf;
g_video_request_header* request = (g_video_request_header*) G_MESSAGE_CONTENT(buf);

if(request->command == G_VIDEO_COMMAND_SET_MODE)
{
efifbDriverHandleCommandSetMode((g_video_set_mode_request*) request, header->sender, header->transaction);
}
else
{
klog("efifbdriver: received unknown command %i from task %i", request->command, header->sender);
}
}
}

void efifbDriverHandleCommandSetMode(g_video_set_mode_request* request, g_tid requestingTaskId,
g_message_transaction requestTransaction)
{
g_address lfb;
uint16_t resX;
uint16_t resY;
uint16_t bpp;
uint32_t pitch;
g_get_efi_framebuffer(&lfb, &resX, &resY, &bpp, &pitch);

uint64_t lfbSize = pitch * resY;
auto localMapped = g_map_mmio((void*) lfb, lfbSize);
// TODO: This is kind of unneccessary, we don't want to map it here
void* addressInRequestersSpace = g_share_mem((void*) localMapped, lfbSize, requestingTaskId);

g_video_set_mode_response response{};
response.status = G_VIDEO_SET_MODE_STATUS_SUCCESS;
response.mode_info.lfb = (g_address) addressInRequestersSpace;
response.mode_info.resX = resX;
response.mode_info.resY = resY;
response.mode_info.bpp = (uint8_t) bpp;
response.mode_info.bpsl = (uint16_t) pitch;
response.mode_info.explicit_update = false;
g_send_message_t(requestingTaskId, &response, sizeof(g_video_set_mode_response), requestTransaction);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,23 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#include "shared/memory/gdt.hpp"
#ifndef __EFIFBDRIVER__
#define __EFIFBDRIVER__

void gdtCreateGate(g_gdt_entry* entry, uint32_t base, uint32_t limit, uint8_t access, uint8_t granularity)
{
entry->baseLow = (base & 0xFFFF);
entry->baseMiddle = (base >> 16) & 0xFF;
entry->baseHigh = (base >> 24) & 0xFF;
#include <libvideo/videodriver.hpp>

entry->limitLow = (limit & 0xFFFF);
entry->limitHigh = limit >> 16;
#include <cstdint>
#include <ghost.h>

entry->granularity = granularity;
/**
* Main loop receiving messages from other processes to do something.
*/
void efifbDriverReceiveMessages();

entry->access = access;
}
/**
* Handles a set-mode command.
*/
void efifbDriverHandleCommandSetMode(g_video_set_mode_request* request, g_tid requestingTaskId,
g_message_transaction requestTransaction);

#endif
8 changes: 8 additions & 0 deletions applications/gsh/src/gosh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include <string.h>
#include <string>

#include <ghost/tasks/types.h>

char* cwdbuf = 0;

std::vector<std::string> gshAutocomplete(std::string toComplete)
Expand Down Expand Up @@ -306,6 +308,12 @@ bool gshHandleBuiltin(program_call_t* call)
return true;
}

if(call->program == "bg")
{
g_spawn(call->arguments.at(0).c_str(), "", "", G_SECURITY_LEVEL_APPLICATION);
return true;
}

if(call->program == "clear" || call->program == "cls")
{
g_terminal::clear();
Expand Down
8 changes: 4 additions & 4 deletions applications/libpci/inc/libpci/driver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ struct g_pci_enable_resource_access_response
/**
* Read a BAR from a device.
*/
bool pciDriverReadBAR(g_pci_device_address address, uint8_t bar, uint32_t* outValue);
bool pciDriverReadBAR(g_pci_device_address address, uint8_t bar, g_address* outValue);

struct g_pci_read_bar_request
{
Expand All @@ -152,13 +152,13 @@ struct g_pci_read_bar_request
struct g_pci_read_bar_response
{
bool successful;
uint32_t value;
g_address value;
}__attribute__((packed));

/**
* Read a BAR size from a device.
*/
bool pciDriverReadBARSize(g_pci_device_address address, uint8_t bar, uint32_t* outValue);
bool pciDriverReadBARSize(g_pci_device_address address, uint8_t bar, g_address* outValue);

struct g_pci_read_bar_size_request
{
Expand All @@ -170,7 +170,7 @@ struct g_pci_read_bar_size_request
struct g_pci_read_bar_size_response
{
bool successful;
uint32_t value;
g_address value;
}__attribute__((packed));

#endif
4 changes: 2 additions & 2 deletions applications/libpci/src/driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ bool pciDriverEnableResourceAccess(g_pci_device_address address, bool enabled)
return success;
}

bool pciDriverReadBAR(g_pci_device_address address, uint8_t bar, uint32_t* outValue)
bool pciDriverReadBAR(g_pci_device_address address, uint8_t bar, g_address* outValue)
{
g_tid driverTid = g_task_await_by_name(G_PCI_DRIVER_NAME);

Expand All @@ -156,7 +156,7 @@ bool pciDriverReadBAR(g_pci_device_address address, uint8_t bar, uint32_t* outVa
return success;
}

bool pciDriverReadBARSize(g_pci_device_address address, uint8_t bar, uint32_t* outValue)
bool pciDriverReadBARSize(g_pci_device_address address, uint8_t bar, g_address* outValue)
{
g_tid driverTid = g_task_await_by_name(G_PCI_DRIVER_NAME);

Expand Down
3 changes: 2 additions & 1 deletion applications/libvideo/inc/libvideo/videodriver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include <stdint.h>
#include <ghost/tasks/types.h>
#include <ghost/memory/types.h>
#include <libdevice/interface.hpp>

struct g_video_mode_info
Expand All @@ -31,7 +32,7 @@ struct g_video_mode_info
uint16_t resY;
uint16_t bpp;
uint16_t bpsl;
uint32_t lfb;
g_address lfb;
bool explicit_update;
}__attribute__((packed));

Expand Down
67 changes: 0 additions & 67 deletions applications/vbedriver/.settings/org.eclipse.cdt.codan.core.prefs

This file was deleted.

Loading
Loading