Skip to content

Commit

Permalink
Intial Support For Mice, test-mouse Program
Browse files Browse the repository at this point in the history
Disabled for now because using the keyboard and mouse at the same time
mess up what both are doing. Mouse can be used by building with
`make mouse=true` and running `test-mouse`,

Also updated README to add this and tweaked other content.
  • Loading branch information
iguessthislldo committed Jan 6, 2023
1 parent 39008a3 commit 5394a54
Show file tree
Hide file tree
Showing 17 changed files with 760 additions and 87 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ endif
ifdef halt_when_done
zig_build_args+="-Dhalt_when_done=$(halt_when_done)"
endif
ifdef mouse
zig_build_args+="-Dmouse=$(mouse)"
endif

all: $(ISO) $(DISK) $(USBDRIVE)

Expand Down
45 changes: 29 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@

![Screenshot of text mode](misc/screenshot1.png)

Georgios (Greek for George, said like *GORE-GEE-OS*) is an operating system I'm
making for fun which currently targets i386/IA-32. The purpose of this project
is to serve as a learning experience.
Georgios (Greek version of the name George, said like *GORE-GEE-OS*) is an
operating system I'm making for fun which currently targets i386/IA-32. The
purpose of this project is to serve as a learning experience.

Work in progress graphics mode:

https://user-images.githubusercontent.com/5941194/180702578-91270793-c91c-4f24-b7e1-f86bc2b48c53.mp4

Georgios is so simplistic right that now the most impressive application is a
snake clone. This is probably going to be the case until applications can be
ported.

## Features

### Working on at least some minimal level
Expand All @@ -26,22 +22,39 @@ ported.
- In-memory filesystem mounted at boot (read/write)
- Basic preemptive multitasking between processes that can be loaded from ELF
files
- ACPI shutdown (thanks in part to [ACPICA](https://www.acpica.org/))
- ACPI shutdown using [ACPICA](https://www.acpica.org/)

### Started on, but not really working yet

- A graphics mode using VESA BIOS Extensions (VBE)
- This makes use of [libx86emu](https://github.com/wfeldt/libx86emu) to
invoke the BIOS code required to access VBE.
- Currently requires building with `make multiboot_vbe=true`
- This will use [libx86emu](https://github.com/wfeldt/libx86emu) to
invoke the BIOS code required to switch to VBE graphics modes. This doesn't
really work yet though.
- This can be bypassed with `make multiboot_vbe=true`, which has GRUB set a
fixed VBE graphics mode. This is how the demo above was ran. This is not
the default for a number of reasons:
- The major reason is the graphics are slow. This can be seen in the
demo, especially when the Apollo earthrise picture takes a moment to
get drawn on the screen.
- It's a fixed graphics mode when the kernel starts and so nothing gets
printed to the screen until the graphical console is ready. So an error
before this wouldn't get printed, which is a problem when running on
real hardware.
- The graphical console is mostly done but missing things like the cursor
and text rendering is a bit off.
- USB 2.0 stack
- Porting real applications written in Zig and C
- The applications currently written in Zig are "real", but are using the
freestanding target and are using system calls directly. To be able to use
a Zig or C hello world program without any modification, the standard
libraries would have to be ported and toolchains would have to be modified
to target Georgios properly.
- The applications currently written in Zig are "real" as in they are
compiled and ran separately from the kernel, are running in x86 ring3, and
can't take the whole system down (for the most part). The issue is they are
compiled using the freestanding target. To be able to use a Zig or C hello
world program without any modification, the standard libraries would have to be
ported and toolchains would have to be modified to target Georgios properly.
- Freeing the OS from the need of a boot CD
- PS/2 Mouse support
- Can be tried out by building with `make mouse=true` and running
`test-mouse`. This isn't enabled by default becuase currently the keyboard
and mouse cross talk when being used at the same time.

## Building

Expand Down
27 changes: 15 additions & 12 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ pub fn build(builder: *std.build.Builder) void {
const multiboot_vbe = b.option(bool, "multiboot_vbe",
\\Ask the bootloader to switch to a graphics mode for us.
) orelse false;
// TODO: Change default to true when Georgios can properly switch to VBE
// itself.
const vbe = b.option(bool, "vbe",
\\Use VBE Graphics if possible.
) orelse multiboot_vbe;
Expand All @@ -74,6 +76,10 @@ pub fn build(builder: *std.build.Builder) void {
const halt_when_done = b.option(bool, "halt_when_done",
\\Halt instead of shutting down.
) orelse false;
// TODO: Change default to true when mouse and keyboard don't conflict.
const mouse = b.option(bool, "mouse",
\\Enable Mouse Support
) orelse false;

target = b.standardTargetOptions(.{
.default_target = std.zig.CrossTarget.parse(.{
Expand Down Expand Up @@ -116,6 +122,7 @@ pub fn build(builder: *std.build.Builder) void {
kernel_options.addOption(bool, "direct_disk", direct_disk);
kernel_options.addOption(bool, "run_rc", run_rc);
kernel_options.addOption(bool, "halt_when_done", halt_when_done);
kernel_options.addOption(bool, "mouse", mouse);
kernel_options.addOption(bool, "is_kernel", true);
kernel.addOptions("build_options", kernel_options);
// Packages
Expand All @@ -136,18 +143,14 @@ pub fn build(builder: *std.build.Builder) void {
catch @panic("generate_builtin_font failed");

// Programs
build_program("shell");
build_program("hello");
build_program("ls");
build_program("cat");
build_program("snake");
build_program("cksum");
build_program("img");
build_program("check-test-file");
build_program("test-prog");
build_program("ed");
// build_zig_program("hello-zig");
// build_c_program("hello-c");
var programs_dir =
std.fs.cwd().openDir("programs", .{.iterate = true}) catch unreachable;
var programs_dir_it = programs_dir.iterate();
while (programs_dir_it.next() catch unreachable) |entry| {
if (entry.kind == .Directory) {
build_program(entry.name);
}
}
}

const disable_ubsan = "-fsanitize-blacklist=misc/clang-sanitize-blacklist.txt";
Expand Down
11 changes: 8 additions & 3 deletions kernel/platform/interrupts.zig
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ var table = table_init: {
break :table_init entries;
};

// TODO: Bochs error for interrupt 39 is missing default error messeage, figure
// TODO: Bochs error for interrupt 39 is missing default error message, figure
// out why.
const invalid_index = "Interrupt number is invalid";
var names = names_init: {
Expand Down Expand Up @@ -395,7 +395,10 @@ pub const pic = struct {
}

pub fn allow_irq(irq: u8, enabled: bool) void {
_ = enabled; // TODO
// TODO
if (!enabled) {
@panic("Trying to use allow_irq(*, false)");
}
var port = irq_0_7_data_port;
if (irq >= 8) {
port = irq_8_15_data_port;
Expand Down Expand Up @@ -429,11 +432,13 @@ pub const pic = struct {
putil.out8(irq_8_15_data_port, 1);
busywork();

// Disable All IRQs for Now
// Disable All IRQs for Now...
putil.out8(irq_0_7_data_port, 0xff);
busywork();
putil.out8(irq_8_15_data_port, 0xff);
busywork();
// Expect for 2 which chains the secondary PIC.
allow_irq(2, true);

// Enable Interrupts
putil.enable_interrupts();
Expand Down
2 changes: 1 addition & 1 deletion kernel/platform/platform.zig
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ pub fn init() !void {

// Setup Devices
kernel.device_mgr.init(kernel.alloc);
ps2.init();
try ps2.init();
pci.find_pci_devices();
bios_int.init();
vbe.init();
Expand Down
Loading

0 comments on commit 5394a54

Please sign in to comment.