Skip to content

Commit 7c2c1c7

Browse files
authored
Merge pull request #48 from maxdev1/x86_64
Port to x86_64, switching from GRUB to Limine
2 parents 8ce4074 + 93664a1 commit 7c2c1c7

File tree

205 files changed

+6447
-5905
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

205 files changed

+6447
-5905
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ documentation/out/*
3939
target/iso/boot/kernel
4040
target/iso/boot/loader
4141
target/iso/boot/ramdisk
42+
target/iso/boot/limine/limine-*.sys
43+
target/iso/boot/limine/limine-*.bin
44+
target/limine-*/*
45+
target/limine-*.tar.gz
46+
47+
node_modules
4248

4349
sysroot/system/include
4450
sysroot/system/lib/*

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ VMSVGA graphics adapter enabled for better performance.
2929
Afterwards, the `target` folder will contain the bootable ISO image.
3030

3131
## Features
32-
* x86-based micro-kernel
32+
* x86_64-based micro-kernel
3333
* SMP multi-processor support
3434
* Comprehensive kernel interaction library (libapi)
3535
* Own C standard library (libc)

applications/ahcidriver/src/ahcidriver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ bool ahciDriverIdentifyController()
7979
devices[i].subclassCode == PCI_01_SUBCLASS_SATA &&
8080
devices[i].progIf == PCI_01_06_PROGIF_AHCI)
8181
{
82-
uint32_t bar;
82+
g_address bar;
8383
if(!pciDriverReadBAR(devices[i].deviceAddress, 5, &bar))
8484
{
8585
klog("Failed to read BAR5 from PCI device %x", devices[i].deviceAddress);

applications/devicemanager/src/manager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ void _deviceManagerCheckPciDevices()
8989
}
9090
else
9191
{
92-
klog("starting VBE driver");
93-
g_spawn("/applications/vbedriver.bin", "", "", G_SECURITY_LEVEL_DRIVER);
92+
klog("starting EFI FB driver");
93+
g_spawn("/applications/efifbdriver.bin", "", "", G_SECURITY_LEVEL_DRIVER);
9494
}
9595
}
9696

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ fi
66
. "$ROOT/ghost.sh"
77

88
# Build configuration
9-
ARTIFACT_NAME="vbedriver.bin"
9+
ARTIFACT_NAME="efifbdriver.bin"
1010
LDFLAGS="-ldevice"
1111

1212
# Include application build tasks
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2+
* *
3+
* Ghost, a micro-kernel based operating system for the x86 architecture *
4+
* Copyright (C) 2015, Max Schlüssel <[email protected]> *
5+
* *
6+
* This program is free software: you can redistribute it and/or modify *
7+
* it under the terms of the GNU General Public License as published by *
8+
* the Free Software Foundation, either version 3 of the License, or *
9+
* (at your option) any later version. *
10+
* *
11+
* This program is distributed in the hope that it will be useful, *
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14+
* GNU General Public License for more details. *
15+
* *
16+
* You should have received a copy of the GNU General Public License *
17+
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
18+
* *
19+
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
20+
21+
#include "efifbdriver.hpp"
22+
23+
#include <libdevice/manager.hpp>
24+
#include <ghost.h>
25+
26+
#include <stdint.h>
27+
#include <string.h>
28+
#include <stdio.h>
29+
30+
g_device_id deviceId;
31+
32+
int main()
33+
{
34+
g_task_register_name("efifbdriver");
35+
36+
if(!deviceManagerRegisterDevice(G_DEVICE_TYPE_VIDEO, g_get_tid(), &deviceId))
37+
{
38+
klog("failed to register device with device manager");
39+
return -1;
40+
}
41+
klog("registered EFI FB device %i", deviceId);
42+
43+
efifbDriverReceiveMessages();
44+
return 0;
45+
}
46+
47+
void efifbDriverReceiveMessages()
48+
{
49+
size_t buflen = sizeof(g_message_header) + 1024;
50+
uint8_t buf[buflen];
51+
52+
for(;;)
53+
{
54+
auto status = g_receive_message(buf, buflen);
55+
if(status != G_MESSAGE_RECEIVE_STATUS_SUCCESSFUL)
56+
{
57+
continue;
58+
}
59+
60+
g_message_header* header = (g_message_header*) buf;
61+
g_video_request_header* request = (g_video_request_header*) G_MESSAGE_CONTENT(buf);
62+
63+
if(request->command == G_VIDEO_COMMAND_SET_MODE)
64+
{
65+
efifbDriverHandleCommandSetMode((g_video_set_mode_request*) request, header->sender, header->transaction);
66+
}
67+
else
68+
{
69+
klog("efifbdriver: received unknown command %i from task %i", request->command, header->sender);
70+
}
71+
}
72+
}
73+
74+
void efifbDriverHandleCommandSetMode(g_video_set_mode_request* request, g_tid requestingTaskId,
75+
g_message_transaction requestTransaction)
76+
{
77+
g_address lfb;
78+
uint16_t resX;
79+
uint16_t resY;
80+
uint16_t bpp;
81+
uint32_t pitch;
82+
g_get_efi_framebuffer(&lfb, &resX, &resY, &bpp, &pitch);
83+
84+
uint64_t lfbSize = pitch * resY;
85+
auto localMapped = g_map_mmio((void*) lfb, lfbSize);
86+
// TODO: This is kind of unneccessary, we don't want to map it here
87+
void* addressInRequestersSpace = g_share_mem((void*) localMapped, lfbSize, requestingTaskId);
88+
89+
g_video_set_mode_response response{};
90+
response.status = G_VIDEO_SET_MODE_STATUS_SUCCESS;
91+
response.mode_info.lfb = (g_address) addressInRequestersSpace;
92+
response.mode_info.resX = resX;
93+
response.mode_info.resY = resY;
94+
response.mode_info.bpp = (uint8_t) bpp;
95+
response.mode_info.bpsl = (uint16_t) pitch;
96+
response.mode_info.explicit_update = false;
97+
g_send_message_t(requestingTaskId, &response, sizeof(g_video_set_mode_response), requestTransaction);
98+
}

kernel/src/shared/memory/gdt.cpp renamed to applications/efifbdriver/src/efifbdriver.hpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,23 @@
1818
* *
1919
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2020

21-
#include "shared/memory/gdt.hpp"
21+
#ifndef __EFIFBDRIVER__
22+
#define __EFIFBDRIVER__
2223

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

29-
entry->limitLow = (limit & 0xFFFF);
30-
entry->limitHigh = limit >> 16;
26+
#include <cstdint>
27+
#include <ghost.h>
3128

32-
entry->granularity = granularity;
29+
/**
30+
* Main loop receiving messages from other processes to do something.
31+
*/
32+
void efifbDriverReceiveMessages();
3333

34-
entry->access = access;
35-
}
34+
/**
35+
* Handles a set-mode command.
36+
*/
37+
void efifbDriverHandleCommandSetMode(g_video_set_mode_request* request, g_tid requestingTaskId,
38+
g_message_transaction requestTransaction);
39+
40+
#endif

applications/gsh/src/gosh.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#include <string.h>
2929
#include <string>
3030

31+
#include <ghost/tasks/types.h>
32+
3133
char* cwdbuf = 0;
3234

3335
std::vector<std::string> gshAutocomplete(std::string toComplete)
@@ -306,6 +308,12 @@ bool gshHandleBuiltin(program_call_t* call)
306308
return true;
307309
}
308310

311+
if(call->program == "bg")
312+
{
313+
g_spawn(call->arguments.at(0).c_str(), "", "", G_SECURITY_LEVEL_APPLICATION);
314+
return true;
315+
}
316+
309317
if(call->program == "clear" || call->program == "cls")
310318
{
311319
g_terminal::clear();

applications/libpci/inc/libpci/driver.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ struct g_pci_enable_resource_access_response
140140
/**
141141
* Read a BAR from a device.
142142
*/
143-
bool pciDriverReadBAR(g_pci_device_address address, uint8_t bar, uint32_t* outValue);
143+
bool pciDriverReadBAR(g_pci_device_address address, uint8_t bar, g_address* outValue);
144144

145145
struct g_pci_read_bar_request
146146
{
@@ -152,13 +152,13 @@ struct g_pci_read_bar_request
152152
struct g_pci_read_bar_response
153153
{
154154
bool successful;
155-
uint32_t value;
155+
g_address value;
156156
}__attribute__((packed));
157157

158158
/**
159159
* Read a BAR size from a device.
160160
*/
161-
bool pciDriverReadBARSize(g_pci_device_address address, uint8_t bar, uint32_t* outValue);
161+
bool pciDriverReadBARSize(g_pci_device_address address, uint8_t bar, g_address* outValue);
162162

163163
struct g_pci_read_bar_size_request
164164
{
@@ -170,7 +170,7 @@ struct g_pci_read_bar_size_request
170170
struct g_pci_read_bar_size_response
171171
{
172172
bool successful;
173-
uint32_t value;
173+
g_address value;
174174
}__attribute__((packed));
175175

176176
#endif

applications/libpci/src/driver.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ bool pciDriverEnableResourceAccess(g_pci_device_address address, bool enabled)
132132
return success;
133133
}
134134

135-
bool pciDriverReadBAR(g_pci_device_address address, uint8_t bar, uint32_t* outValue)
135+
bool pciDriverReadBAR(g_pci_device_address address, uint8_t bar, g_address* outValue)
136136
{
137137
g_tid driverTid = g_task_await_by_name(G_PCI_DRIVER_NAME);
138138

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

159-
bool pciDriverReadBARSize(g_pci_device_address address, uint8_t bar, uint32_t* outValue)
159+
bool pciDriverReadBARSize(g_pci_device_address address, uint8_t bar, g_address* outValue)
160160
{
161161
g_tid driverTid = g_task_await_by_name(G_PCI_DRIVER_NAME);
162162

0 commit comments

Comments
 (0)