Compare commits
29 commits
bochs-grap
...
master
Author | SHA1 | Date | |
---|---|---|---|
able | 773709c035 | ||
able | 53317e6935 | ||
2059f09675 | |||
c2ad9a0155 | |||
86fc89f060 | |||
bd91dae004 | |||
a0d5ccfd2c | |||
f88a4cfc07 | |||
1c0b29dba2 | |||
4c782615c5 | |||
46f5302cd1 | |||
9a7efbd3ef | |||
d2f3b66381 | |||
40e62a9536 | |||
d80449dc8e | |||
8b805d7c3b | |||
38cc3a9868 | |||
c86da4b2ba | |||
fd0be9b608 | |||
53395cb9ed | |||
1628ab2c79 | |||
3544c8ca79 | |||
c5d21bd38c | |||
b1d71e76d8 | |||
3a5e941966 | |||
c711f22e63 | |||
7ff25184ce | |||
135edda3ab | |||
4a5598e072 |
10
.github/workflows/rust.yml
vendored
10
.github/workflows/rust.yml
vendored
|
@ -29,7 +29,7 @@ jobs:
|
|||
- name: Install Rustup
|
||||
run: |
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly
|
||||
echo ::add-path::$HOME/.cargo/bin
|
||||
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
|
||||
if: runner.os == 'macOS'
|
||||
|
||||
- name: "Print Rust Version"
|
||||
|
@ -43,7 +43,7 @@ jobs:
|
|||
path: binaries
|
||||
key: ${{ runner.OS }}-binaries
|
||||
- name: Add binaries/bin to PATH
|
||||
run: echo ::add-path::$GITHUB_WORKSPACE/binaries/bin
|
||||
run: echo "$GITHUB_WORKSPACE/binaries/bin" >> $GITHUB_PATH
|
||||
shell: bash
|
||||
|
||||
- name: "Run cargo build"
|
||||
|
@ -75,7 +75,7 @@ jobs:
|
|||
- name: Install Scoop (Windows)
|
||||
run: |
|
||||
Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
|
||||
echo ::add-path::$HOME\scoop\shims
|
||||
echo "$HOME\scoop\shims" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
||||
if: runner.os == 'Windows'
|
||||
shell: pwsh
|
||||
- name: Install QEMU (Windows)
|
||||
|
@ -100,7 +100,7 @@ jobs:
|
|||
timeout-minutes: 2
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- run: rustup install nightly
|
||||
- run: rustup toolchain install nightly --profile minimal --component rustfmt
|
||||
- run: cargo +nightly fmt -- --check
|
||||
|
||||
clippy:
|
||||
|
@ -109,5 +109,5 @@ jobs:
|
|||
timeout-minutes: 10
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- run: rustup install nightly
|
||||
- run: rustup toolchain install nightly --profile minimal --component clippy
|
||||
- run: cargo +nightly clippy -- -D warnings
|
||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
/target
|
||||
/testing/target
|
||||
/testing/binaries
|
||||
Cargo.lock
|
||||
|
|
30
Cargo.toml
30
Cargo.toml
|
@ -1,17 +1,12 @@
|
|||
[package]
|
||||
name = "vga"
|
||||
version = "0.2.3"
|
||||
version = "0.2.7"
|
||||
authors = ["Ryan Kennedy <rkennedy9064@gmail.com>"]
|
||||
edition = "2018"
|
||||
description = "Support for vga specific functions, data structures, and registers."
|
||||
documentation = "https://docs.rs/vga"
|
||||
keywords = [
|
||||
"vga",
|
||||
"no_std",
|
||||
]
|
||||
categories = [
|
||||
"no-std",
|
||||
]
|
||||
keywords = ["vga", "no_std"]
|
||||
categories = ["no-std"]
|
||||
license = "MIT/Apache-2.0"
|
||||
readme = "README.md"
|
||||
repository = "https://github.com/rust-osdev/vga"
|
||||
|
@ -20,11 +15,20 @@ repository = "https://github.com/rust-osdev/vga"
|
|||
|
||||
[dependencies]
|
||||
bitflags = "1.2.1"
|
||||
conquer-once = { version = "0.2.0", default-features = false }
|
||||
font8x8 = { version = "0.2.5", default-features = false, features = ["unicode"] }
|
||||
spinning_top = { version = "0.1.0", features = ["nightly"] }
|
||||
x86_64 = "0.9.6"
|
||||
spin = "0.9"
|
||||
log = "*"
|
||||
|
||||
conquer-once = { version = "0.3.2", default-features = false }
|
||||
font8x8 = { version = "0.3.1", default-features = false, features = [
|
||||
"unicode",
|
||||
] }
|
||||
spinning_top = { version = "0.2.4", features = ["nightly"] }
|
||||
x86_64 = "0.14.2"
|
||||
[dependencies.num-traits]
|
||||
version = "0.2.11"
|
||||
version = "0.2.14"
|
||||
default-features = false
|
||||
|
||||
[dependencies.ab_glyph]
|
||||
version = "0.2.15"
|
||||
default-features = false
|
||||
features = ["libm"]
|
||||
|
|
12
Changelog.md
12
Changelog.md
|
@ -1,3 +1,15 @@
|
|||
# 0.2.6
|
||||
|
||||
- Updatex `x86_64` to build with lastest rust nightly.
|
||||
|
||||
# 0.2.5
|
||||
|
||||
- Updated various out of date crates.
|
||||
|
||||
# 0.2.4
|
||||
|
||||
- Updated `x86_64` to fix deprecated `asm!` macro.
|
||||
|
||||
# 0.2.3
|
||||
|
||||
- Added support for 320x240x256 mode via `Graphics320x240x256`.
|
||||
|
|
BIN
assets/fonts/unifont-14.0.01.ttf
Normal file
BIN
assets/fonts/unifont-14.0.01.ttf
Normal file
Binary file not shown.
BIN
assets/fonts/unifont_upper-14.0.01.ttf
Normal file
BIN
assets/fonts/unifont_upper-14.0.01.ttf
Normal file
Binary file not shown.
|
@ -69,7 +69,6 @@ impl TextModeColor {
|
|||
self.0 = foreground as u8;
|
||||
}
|
||||
}
|
||||
|
||||
/// Represents the default vga 256 color palette.
|
||||
pub const DEFAULT_PALETTE: [u8; PALETTE_SIZE] = [
|
||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x2A, 0x0, 0x2A, 0x0, 0x0, 0x2A, 0x2A, 0x2A, 0x0, 0x0, 0x2A, 0x0,
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#![no_std]
|
||||
#![warn(missing_docs)]
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
pub mod colors;
|
||||
pub mod configurations;
|
||||
pub mod drawing;
|
||||
|
|
|
@ -5,6 +5,7 @@ use crate::{
|
|||
registers::{PlaneMask, WriteMode},
|
||||
vga::{VideoMode, VGA},
|
||||
};
|
||||
use core::convert::From;
|
||||
use font8x8::UnicodeFonts;
|
||||
|
||||
const WIDTH: usize = 640;
|
||||
|
@ -122,15 +123,89 @@ impl Graphics640x480x16 {
|
|||
|
||||
#[inline]
|
||||
fn _set_pixel(self, x: usize, y: usize, color: Color16) {
|
||||
let frame_buffer = self.get_frame_buffer();
|
||||
let offset = x / 8 + y * WIDTH_IN_BYTES;
|
||||
let pixel_mask = 0x80 >> (x & 0x07);
|
||||
VGA.lock()
|
||||
.graphics_controller_registers
|
||||
.set_bit_mask(pixel_mask);
|
||||
unsafe {
|
||||
frame_buffer.add(offset).read_volatile();
|
||||
frame_buffer.add(offset).write_volatile(u8::from(color));
|
||||
if x < 640 && y < 480 {
|
||||
let frame_buffer = self.get_frame_buffer();
|
||||
let offset = x / 8 + y * WIDTH_IN_BYTES;
|
||||
let pixel_mask = 0x80 >> (x & 0x07);
|
||||
VGA.lock()
|
||||
.graphics_controller_registers
|
||||
.set_bit_mask(pixel_mask);
|
||||
unsafe {
|
||||
frame_buffer.add(offset).read_volatile();
|
||||
frame_buffer.add(offset).write_volatile(u8::from(color));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
use ab_glyph::{Font, FontRef, Glyph};
|
||||
use log::trace;
|
||||
use spin::Lazy;
|
||||
|
||||
const FONT_BASIC: Lazy<FontRef> = Lazy::new({
|
||||
|| FontRef::try_from_slice(include_bytes!("../../assets/fonts/unifont-14.0.01.ttf")).unwrap()
|
||||
});
|
||||
|
||||
const FONT_SUPPLEMENTARY: Lazy<FontRef> = Lazy::new(|| {
|
||||
FontRef::try_from_slice(include_bytes!(
|
||||
"../../assets/fonts/unifont_upper-14.0.01.ttf"
|
||||
))
|
||||
.unwrap()
|
||||
});
|
||||
|
||||
const FONT_SCALE: f32 = 14.0;
|
||||
const GLYPH_HEIGHT: f32 = 10.0;
|
||||
const GLYPH_WIDTH: f32 = 8.0;
|
||||
|
||||
impl Graphics640x480x16 {
|
||||
/// Draw a glyph on the screen at the given position
|
||||
///
|
||||
/// # Arguments
|
||||
/// * `x` - the x position of the glyph
|
||||
/// * `y` - the y position of the glyph
|
||||
/// * `glyph` - the glyph to draw
|
||||
/// * `color` - the color of the glyph
|
||||
pub fn draw_unicode_char(&self, mut x: usize, mut y: usize, character: char, color: Color16) {
|
||||
self.set_write_mode_2();
|
||||
|
||||
// trace!("Char {}", character);
|
||||
|
||||
// if character == '\n' {
|
||||
// return;
|
||||
// }
|
||||
if x == 80 {
|
||||
x = 0;
|
||||
y += 1;
|
||||
}
|
||||
|
||||
if character != '\0' {
|
||||
let real_x = x as f32 * GLYPH_WIDTH;
|
||||
let real_y = (y as f32 + 1.0) * GLYPH_HEIGHT;
|
||||
// trace!("REALX{}\nREALY{}", real_x, real_y);
|
||||
|
||||
let in_supp_plane = character as u32 > 0xffff;
|
||||
|
||||
let plane = match in_supp_plane {
|
||||
false => FONT_BASIC,
|
||||
true => FONT_SUPPLEMENTARY,
|
||||
};
|
||||
|
||||
let q_glyph: Glyph = plane
|
||||
.glyph_id(character)
|
||||
.with_scale_and_position(FONT_SCALE, ab_glyph::point(real_x, real_y));
|
||||
|
||||
if let Some(q) = plane.outline_glyph(q_glyph) {
|
||||
q.draw(|gx, gy, c| {
|
||||
if c > 0.1 {
|
||||
let corner = q.px_bounds().min;
|
||||
self._set_pixel(
|
||||
gx as usize + corner.x as usize,
|
||||
gy as usize + corner.y as usize,
|
||||
color,
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,13 +5,13 @@ authors = ["Ryan Kennedy <rkennedy9064@gmail.com>"]
|
|||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
bootloader = { version = "0.9.0", features = ["map_physical_memory"] }
|
||||
conquer-once = { version = "0.2.0", default-features = false }
|
||||
spinning_top = { version = "0.1.0", features = ["nightly"] }
|
||||
pic8259_simple = "0.1.1"
|
||||
bootloader = { version = "0.9.11", features = ["map_physical_memory"] }
|
||||
conquer-once = { version = "0.3.2", default-features = false }
|
||||
spinning_top = { version = "0.2.4", features = ["nightly"] }
|
||||
pic8259 = "0.10.1"
|
||||
vga = { path = "../" }
|
||||
uart_16550 = "0.2.4"
|
||||
x86_64 = "0.9.6"
|
||||
uart_16550 = "0.2.14"
|
||||
x86_64 = "0.14.2"
|
||||
|
||||
[package.metadata.bootimage]
|
||||
test-args = [
|
||||
|
|
|
@ -2,7 +2,7 @@ use crate::gdt;
|
|||
use crate::{hlt_loop, serial_print, serial_println};
|
||||
use conquer_once::spin::Lazy;
|
||||
use core::convert::Into;
|
||||
use pic8259_simple::ChainedPics;
|
||||
use pic8259::ChainedPics;
|
||||
use spinning_top::Spinlock;
|
||||
use x86_64::structures::idt::{InterruptDescriptorTable, InterruptStackFrame, PageFaultErrorCode};
|
||||
|
||||
|
@ -49,14 +49,14 @@ pub fn init_idt() {
|
|||
}
|
||||
|
||||
extern "x86-interrupt" fn double_fault_handler(
|
||||
stack_frame: &mut InterruptStackFrame,
|
||||
stack_frame: InterruptStackFrame,
|
||||
_error_code: u64,
|
||||
) -> ! {
|
||||
panic!("EXCEPTION: DOUBLE FAULT\n{:#?}", stack_frame);
|
||||
}
|
||||
|
||||
extern "x86-interrupt" fn page_fault_handler(
|
||||
stack_frame: &mut InterruptStackFrame,
|
||||
stack_frame: InterruptStackFrame,
|
||||
error_code: PageFaultErrorCode,
|
||||
) {
|
||||
use x86_64::registers::control::Cr2;
|
||||
|
@ -69,7 +69,7 @@ extern "x86-interrupt" fn page_fault_handler(
|
|||
}
|
||||
|
||||
extern "x86-interrupt" fn segment_not_present(
|
||||
_stack_frame: &mut InterruptStackFrame,
|
||||
_stack_frame: InterruptStackFrame,
|
||||
_error_code: u64,
|
||||
) {
|
||||
// For some reason this sometimes gets thrown when running tests in qemu,
|
||||
|
|
Loading…
Reference in a new issue