Skip to content

Working on a port to x86_64, switching from GRUB to Limine #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 19 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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 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);
}
40 changes: 40 additions & 0 deletions applications/efifbdriver/src/efifbdriver.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* 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/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#ifndef __EFIFBDRIVER__
#define __EFIFBDRIVER__

#include <libvideo/videodriver.hpp>

#include <cstdint>
#include <ghost.h>

/**
* Main loop receiving messages from other processes to do something.
*/
void efifbDriverReceiveMessages();

/**
* 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