From faaadcf4750583f615abd9c258d164a1280de75c Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Sat, 29 Jan 2022 23:15:39 -0800 Subject: [PATCH] Move lightshow into dir Note: this currently has a rustc compiler panic trying to use the `#[no_core]` attribute, which seems poorly supported --- README.md | 1 + justfile | 13 +++++++++++++ lightshow.asm => lightshow/lightshow.asm | 6 +++--- lightshow.rs => lightshow/lightshow.rs | 21 +++++++++++++++------ 4 files changed, 32 insertions(+), 9 deletions(-) rename lightshow.asm => lightshow/lightshow.asm (79%) rename lightshow.rs => lightshow/lightshow.rs (70%) diff --git a/README.md b/README.md index 3733ada..1d2f01d 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ This repo contains the following executables: * `gamarjoba_munde` - x86-64 linux binary that prints the text "Gamarjoba, Munde" * `baremetal_gamarjoba` - bare-metal x86 program run with QEMU * `keyboard` - reads keycode information from keyboard. Also uses both Rust and C includes. +* `lightshow` - NOTE: Broken - an attempt at a substantial #[no_core] rust object file, currently crashes rustc # Useful links diff --git a/justfile b/justfile index 6b2615b..adda797 100644 --- a/justfile +++ b/justfile @@ -35,3 +35,16 @@ run_keyboard: build_keyboard run_terminal_keyboard: build_keyboard qemu-system-i386 -display curses -kernel keyboard/keyboard_kernel + +build_lightshow: + #!/usr/bin/env bash + cd lightshow + rustc --emit obj -o lightshow_rust.o --target i686-unknown-linux-gnu -g lightshow.rs + nasm -f elf32 -i ../common -g lightshow.asm + ld -m elf_i386 -nostdlib -T ../common/linker.ld lightshow.o lightshow_rust.o -o lightshow + +run_lightshow: build_lightshow + qemu-system-i386 -kernel lightshow + +debug_lightshow: build_lightshow + qemu-system-i386 -kernel lightshow -gdb tcp::9999 -S diff --git a/lightshow.asm b/lightshow/lightshow.asm similarity index 79% rename from lightshow.asm rename to lightshow/lightshow.asm index 90afa67..3758923 100644 --- a/lightshow.asm +++ b/lightshow/lightshow.asm @@ -1,4 +1,4 @@ -%include "x86_vram.asm" +%include "../common/x86_vram.asm" extern rust_entry @@ -12,8 +12,8 @@ section .data section .text global boot -%include "multiboot_header.asm" -%include "x86_vram_functions.asm" +%include "../common/multiboot_header.asm" +%include "../common/x86_vram_functions.asm" boot: mov esp, stack + 0x100 diff --git a/lightshow.rs b/lightshow/lightshow.rs similarity index 70% rename from lightshow.rs rename to lightshow/lightshow.rs index f660b95..4ff292d 100644 --- a/lightshow.rs +++ b/lightshow/lightshow.rs @@ -1,5 +1,5 @@ -#![feature(lang_items, start, no_core)] +#![feature(lang_items, no_core)] #![no_core] #![no_main] @@ -10,10 +10,18 @@ extern fn eh_personality() {} fn panic_fmt() -> ! { loop {} } #[lang = "panic"] -pub fn panic(expr_file_line: &(&'static str, &'static str, u32)) -> ! { panic_fmt() } +pub fn panic(_expr_file_line: &(&'static str, &'static str, u32)) -> ! { panic_fmt() } + +#[lang = "panic_location"] +struct Location<'a> { + _file: &'a str, + _line: u32, + _col: u32, +} + #[lang = "sized"] -trait Sized {} +pub trait Sized {} #[lang = "copy"] trait Copy {} @@ -21,7 +29,7 @@ trait Copy {} #[lang = "add"] pub trait Add { type Output; - fn add(self, rhs: RHS) -> Self::Output; + fn add(self, _rhs: RHS) -> Self::Output; } /* this can be bogus, apparently? */ @@ -33,12 +41,12 @@ impl Add for usize { #[lang = "mul"] pub trait Mul { type Output; - fn mul(self, rhs: RHS) -> Self::Output; + fn mul(self, _rhs: RHS) -> Self::Output; } impl Mul for usize { type Output = usize; - fn mul(self, rhs: usize) -> usize { 1 } + fn mul(self, _rhs: usize) -> usize { 1 } } @@ -54,6 +62,7 @@ pub extern fn rust_entry() { } const X86_COLS: usize = 80; +#[allow(dead_code)] const X86_ROWS: usize = 25; const VRAM_OFFSET: usize = 0xb8000;