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
|
- name: Install Rustup
|
||||||
run: |
|
run: |
|
||||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain nightly
|
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'
|
if: runner.os == 'macOS'
|
||||||
|
|
||||||
- name: "Print Rust Version"
|
- name: "Print Rust Version"
|
||||||
|
@ -43,7 +43,7 @@ jobs:
|
||||||
path: binaries
|
path: binaries
|
||||||
key: ${{ runner.OS }}-binaries
|
key: ${{ runner.OS }}-binaries
|
||||||
- name: Add binaries/bin to PATH
|
- name: Add binaries/bin to PATH
|
||||||
run: echo ::add-path::$GITHUB_WORKSPACE/binaries/bin
|
run: echo "$GITHUB_WORKSPACE/binaries/bin" >> $GITHUB_PATH
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- name: "Run cargo build"
|
- name: "Run cargo build"
|
||||||
|
@ -75,7 +75,7 @@ jobs:
|
||||||
- name: Install Scoop (Windows)
|
- name: Install Scoop (Windows)
|
||||||
run: |
|
run: |
|
||||||
Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
|
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'
|
if: runner.os == 'Windows'
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
- name: Install QEMU (Windows)
|
- name: Install QEMU (Windows)
|
||||||
|
@ -100,7 +100,7 @@ jobs:
|
||||||
timeout-minutes: 2
|
timeout-minutes: 2
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
- run: rustup install nightly
|
- run: rustup toolchain install nightly --profile minimal --component rustfmt
|
||||||
- run: cargo +nightly fmt -- --check
|
- run: cargo +nightly fmt -- --check
|
||||||
|
|
||||||
clippy:
|
clippy:
|
||||||
|
@ -109,5 +109,5 @@ jobs:
|
||||||
timeout-minutes: 10
|
timeout-minutes: 10
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
- run: rustup install nightly
|
- run: rustup toolchain install nightly --profile minimal --component clippy
|
||||||
- run: cargo +nightly clippy -- -D warnings
|
- run: cargo +nightly clippy -- -D warnings
|
||||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
||||||
/target
|
/target
|
||||||
/testing/target
|
/testing/target
|
||||||
|
/testing/binaries
|
||||||
Cargo.lock
|
Cargo.lock
|
||||||
|
|
30
Cargo.toml
30
Cargo.toml
|
@ -1,17 +1,12 @@
|
||||||
[package]
|
[package]
|
||||||
name = "vga"
|
name = "vga"
|
||||||
version = "0.2.3"
|
version = "0.2.7"
|
||||||
authors = ["Ryan Kennedy <rkennedy9064@gmail.com>"]
|
authors = ["Ryan Kennedy <rkennedy9064@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
description = "Support for vga specific functions, data structures, and registers."
|
description = "Support for vga specific functions, data structures, and registers."
|
||||||
documentation = "https://docs.rs/vga"
|
documentation = "https://docs.rs/vga"
|
||||||
keywords = [
|
keywords = ["vga", "no_std"]
|
||||||
"vga",
|
categories = ["no-std"]
|
||||||
"no_std",
|
|
||||||
]
|
|
||||||
categories = [
|
|
||||||
"no-std",
|
|
||||||
]
|
|
||||||
license = "MIT/Apache-2.0"
|
license = "MIT/Apache-2.0"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
repository = "https://github.com/rust-osdev/vga"
|
repository = "https://github.com/rust-osdev/vga"
|
||||||
|
@ -20,11 +15,20 @@ repository = "https://github.com/rust-osdev/vga"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bitflags = "1.2.1"
|
bitflags = "1.2.1"
|
||||||
conquer-once = { version = "0.2.0", default-features = false }
|
spin = "0.9"
|
||||||
font8x8 = { version = "0.2.5", default-features = false, features = ["unicode"] }
|
log = "*"
|
||||||
spinning_top = { version = "0.1.0", features = ["nightly"] }
|
|
||||||
x86_64 = "0.9.6"
|
|
||||||
|
|
||||||
|
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]
|
[dependencies.num-traits]
|
||||||
version = "0.2.11"
|
version = "0.2.14"
|
||||||
default-features = false
|
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
|
# 0.2.3
|
||||||
|
|
||||||
- Added support for 320x240x256 mode via `Graphics320x240x256`.
|
- 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;
|
self.0 = foreground as u8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents the default vga 256 color palette.
|
/// Represents the default vga 256 color palette.
|
||||||
pub const DEFAULT_PALETTE: [u8; PALETTE_SIZE] = [
|
pub const DEFAULT_PALETTE: [u8; PALETTE_SIZE] = [
|
||||||
0x0, 0x0, 0x0, 0x0, 0x0, 0x2A, 0x0, 0x2A, 0x0, 0x0, 0x2A, 0x2A, 0x2A, 0x0, 0x0, 0x2A, 0x0,
|
0x0, 0x0, 0x0, 0x0, 0x0, 0x2A, 0x0, 0x2A, 0x0, 0x0, 0x2A, 0x2A, 0x2A, 0x0, 0x0, 0x2A, 0x0,
|
||||||
|
|
|
@ -1,245 +0,0 @@
|
||||||
use super::pci::{find_pci_device, PciDevice};
|
|
||||||
use crate::{
|
|
||||||
drawing::{Bresenham, Point, Rectangle},
|
|
||||||
writers::GraphicsWriter,
|
|
||||||
};
|
|
||||||
use font8x8::UnicodeFonts;
|
|
||||||
use x86_64::{instructions::port::Port, PhysAddr, VirtAddr};
|
|
||||||
|
|
||||||
const BOCHS_ID: u32 = 0x1111_1234;
|
|
||||||
const BOCHS_INDEX_PORT_ADDRESS: u16 = 0x01CE;
|
|
||||||
const BOCHS_DATA_PORT_ADDRESS: u16 = 0x01CF;
|
|
||||||
|
|
||||||
const VBE_DISPI_INDEX_XRES: u16 = 0x01;
|
|
||||||
const VBE_DISPI_INDEX_YRES: u16 = 0x02;
|
|
||||||
const VBE_DISPI_INDEX_BPP: u16 = 0x03;
|
|
||||||
const VBE_DISPI_INDEX_ENABLE: u16 = 0x04;
|
|
||||||
|
|
||||||
const VBE_DISPI_DISABLED: u16 = 0x00;
|
|
||||||
const VBE_DISPI_ENABLED: u16 = 0x01;
|
|
||||||
const VBE_DISPI_GETCAPS: u16 = 0x02;
|
|
||||||
const VBE_DISPI_LFB_ENABLED: u16 = 0x40;
|
|
||||||
const VBE_DISPI_BPP_32: u16 = 0x20;
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Default)]
|
|
||||||
pub struct Resolution {
|
|
||||||
width: usize,
|
|
||||||
height: usize,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Resolution {
|
|
||||||
pub fn new(width: usize, height: usize) -> Resolution {
|
|
||||||
Resolution { width, height }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct BochsDevice {
|
|
||||||
index_port: Port<u16>,
|
|
||||||
data_port: Port<u16>,
|
|
||||||
pci_device: PciDevice,
|
|
||||||
physical_address: PhysAddr,
|
|
||||||
virtual_address: VirtAddr,
|
|
||||||
resolution: Resolution,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl BochsDevice {
|
|
||||||
pub fn new(width: usize, height: usize) -> BochsDevice {
|
|
||||||
let pci_device = find_pci_device(BOCHS_ID).expect("no bochs device found");
|
|
||||||
let index_port = Port::new(BOCHS_INDEX_PORT_ADDRESS);
|
|
||||||
let data_port = Port::new(BOCHS_DATA_PORT_ADDRESS);
|
|
||||||
let base_address = pci_device.base_addresses[0] & 0xFFFF_FFF0;
|
|
||||||
let physical_address = PhysAddr::new(base_address as u64);
|
|
||||||
let virtual_address = VirtAddr::new(base_address as u64);
|
|
||||||
let resolution = Resolution::new(width, height);
|
|
||||||
BochsDevice {
|
|
||||||
pci_device,
|
|
||||||
index_port,
|
|
||||||
data_port,
|
|
||||||
physical_address,
|
|
||||||
virtual_address,
|
|
||||||
resolution,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The physical address the frame buffer is mapped to.
|
|
||||||
pub fn physical_address(&self) -> PhysAddr {
|
|
||||||
self.physical_address
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The virtual address that's written to for graphics operations.
|
|
||||||
///
|
|
||||||
/// **Note:** This address is set to the `physical_address` of the frame buffer
|
|
||||||
/// by default. If you map the `physical_address` to a different location, `virtual_address`
|
|
||||||
/// must be set using `set_virtual_address`.
|
|
||||||
pub fn virtual_address(&self) -> VirtAddr {
|
|
||||||
self.virtual_address
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Sets the `virtual_address` that's written to for graphics operations.
|
|
||||||
pub fn set_virtual_address(&mut self, virtual_address: VirtAddr) {
|
|
||||||
self.virtual_address = virtual_address;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns the max capabilities supported by the `BochsDevice`.
|
|
||||||
pub fn capabilities(&mut self) -> Resolution {
|
|
||||||
unsafe {
|
|
||||||
// Save original value of VBE_DISPI_INDEX_ENABLE
|
|
||||||
self.index_port.write(VBE_DISPI_INDEX_ENABLE);
|
|
||||||
let original_value = self.data_port.read();
|
|
||||||
self.data_port.write(VBE_DISPI_GETCAPS);
|
|
||||||
|
|
||||||
// Read max width
|
|
||||||
self.index_port.write(VBE_DISPI_INDEX_XRES);
|
|
||||||
let width = self.data_port.read() as usize;
|
|
||||||
|
|
||||||
// Read max height
|
|
||||||
self.index_port.write(VBE_DISPI_INDEX_YRES);
|
|
||||||
let height = self.data_port.read() as usize;
|
|
||||||
|
|
||||||
// Restore original VBE_DISPI_INDEX_ENABLE
|
|
||||||
self.index_port.write(VBE_DISPI_INDEX_ENABLE);
|
|
||||||
self.data_port.write(original_value);
|
|
||||||
|
|
||||||
Resolution { width, height }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn disable_display(&mut self) {
|
|
||||||
unsafe {
|
|
||||||
self.index_port.write(VBE_DISPI_INDEX_ENABLE);
|
|
||||||
self.data_port.write(VBE_DISPI_DISABLED);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn enable_display(&mut self) {
|
|
||||||
unsafe {
|
|
||||||
self.index_port.write(VBE_DISPI_INDEX_ENABLE);
|
|
||||||
self.data_port
|
|
||||||
.write(VBE_DISPI_ENABLED | VBE_DISPI_LFB_ENABLED);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns the current resolution the `BochsDevice` is set to.
|
|
||||||
pub fn current_resolution(&mut self) -> Resolution {
|
|
||||||
let width = self.get_width();
|
|
||||||
let height = self.get_height();
|
|
||||||
Resolution { width, height }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Sets the `BochsDevice` to the given `resolution`.
|
|
||||||
pub fn set_resolution(&mut self, resolution: Resolution) {
|
|
||||||
self.resolution = resolution;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_width(&mut self) -> usize {
|
|
||||||
unsafe {
|
|
||||||
self.index_port.write(VBE_DISPI_INDEX_XRES);
|
|
||||||
self.data_port.read() as usize
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_height(&mut self) -> usize {
|
|
||||||
unsafe {
|
|
||||||
self.index_port.write(VBE_DISPI_INDEX_YRES);
|
|
||||||
self.data_port.read() as usize
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_width(&mut self, width: usize) {
|
|
||||||
unsafe {
|
|
||||||
self.index_port.write(VBE_DISPI_INDEX_XRES);
|
|
||||||
self.data_port.write(width as u16);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_height(&mut self, height: usize) {
|
|
||||||
unsafe {
|
|
||||||
self.index_port.write(VBE_DISPI_INDEX_YRES);
|
|
||||||
self.data_port.write(height as u16);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_bpp(&mut self) {
|
|
||||||
unsafe {
|
|
||||||
self.index_port.write(VBE_DISPI_INDEX_BPP);
|
|
||||||
self.data_port.write(VBE_DISPI_BPP_32);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl GraphicsWriter<u32> for BochsDevice {
|
|
||||||
fn clear_screen(&self, color: u32) {
|
|
||||||
let screen_size = self.resolution.width * self.resolution.height;
|
|
||||||
let frame_buffer = self.virtual_address.as_mut_ptr::<u32>();
|
|
||||||
for offset in 0..screen_size {
|
|
||||||
unsafe {
|
|
||||||
frame_buffer.add(offset).write_volatile(color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn draw_character(&self, x: usize, y: usize, character: char, color: u32) {
|
|
||||||
let character = match font8x8::BASIC_FONTS.get(character) {
|
|
||||||
Some(character) => character,
|
|
||||||
// Default to a filled block if the character isn't found
|
|
||||||
None => font8x8::unicode::BLOCK_UNICODE[8].byte_array(),
|
|
||||||
};
|
|
||||||
|
|
||||||
for (row, byte) in character.iter().enumerate() {
|
|
||||||
for bit in 0..8 {
|
|
||||||
match *byte & 1 << bit {
|
|
||||||
0 => (),
|
|
||||||
_ => self.set_pixel(x + bit, y + row, color),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn draw_rectangle(&self, rectangle: &Rectangle, color: u32) {
|
|
||||||
let p1 = (rectangle.x as isize, rectangle.y as isize);
|
|
||||||
let p2 = (rectangle.x as isize, rectangle.bottom() as isize);
|
|
||||||
let p3 = (rectangle.right() as isize, rectangle.bottom() as isize);
|
|
||||||
let p4 = (rectangle.right() as isize, rectangle.y as isize);
|
|
||||||
self.draw_line(p1, p2, color);
|
|
||||||
self.draw_line(p2, p3, color);
|
|
||||||
self.draw_line(p3, p4, color);
|
|
||||||
self.draw_line(p4, p1, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn draw_filled_rectangle(&self, rectangle: &Rectangle, color: u32) {
|
|
||||||
for y in rectangle.y..rectangle.bottom() {
|
|
||||||
for x in rectangle.x..rectangle.right() {
|
|
||||||
self.set_pixel(x as usize, y as usize, color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn draw_line(&self, start: Point<isize>, end: Point<isize>, color: u32) {
|
|
||||||
for (x, y) in Bresenham::new(start, end) {
|
|
||||||
self.set_pixel(x as usize, y as usize, color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_pixel(&self, x: usize, y: usize, color: u32) {
|
|
||||||
let offset = (y * self.resolution.width) + x;
|
|
||||||
unsafe {
|
|
||||||
self.virtual_address
|
|
||||||
.as_mut_ptr::<u32>()
|
|
||||||
.add(offset)
|
|
||||||
.write_volatile(color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_frame_buffer(&self) -> *mut u32 {
|
|
||||||
self.virtual_address.as_mut_ptr()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_mode(&mut self) {
|
|
||||||
self.disable_display();
|
|
||||||
self.set_width(self.resolution.width);
|
|
||||||
self.set_height(self.resolution.height);
|
|
||||||
self.set_bpp();
|
|
||||||
self.enable_display();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
pub mod bochs;
|
|
||||||
mod pci;
|
|
||||||
|
|
||||||
pub use bochs::{BochsDevice, Resolution};
|
|
|
@ -1,126 +0,0 @@
|
||||||
use x86_64::instructions::port::Port;
|
|
||||||
|
|
||||||
const BUSSES: u32 = 256;
|
|
||||||
const SLOTS: u32 = 32;
|
|
||||||
const FUNCTIONS: u32 = 8;
|
|
||||||
|
|
||||||
const CONFIG_ADDRESS: u16 = 0xCF8;
|
|
||||||
const DATA_ADDRESS: u16 = 0xCFC;
|
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone)]
|
|
||||||
pub(crate) struct PciDevice {
|
|
||||||
vendor_id: u16,
|
|
||||||
device_id: u16,
|
|
||||||
command: u16,
|
|
||||||
status: u16,
|
|
||||||
revision_id: u8,
|
|
||||||
prog_if: u8,
|
|
||||||
sub_class: u8,
|
|
||||||
base_class: u8,
|
|
||||||
cache_line_size: u8,
|
|
||||||
latency_timer: u8,
|
|
||||||
header_type: u8,
|
|
||||||
bist: u8,
|
|
||||||
pub(crate) base_addresses: [u32; 6],
|
|
||||||
cis: u32,
|
|
||||||
sub_vendor_id: u16,
|
|
||||||
sub_system_id: u16,
|
|
||||||
rom_base_address: u32,
|
|
||||||
reserved_2: [u32; 2],
|
|
||||||
interrupt_line: u8,
|
|
||||||
interrupt_pin: u8,
|
|
||||||
minimum_grant: u8,
|
|
||||||
maximum_latency: u8,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn find_pci_device(device_id: u32) -> Option<PciDevice> {
|
|
||||||
for bus in 0..BUSSES {
|
|
||||||
for slot in 0..SLOTS {
|
|
||||||
for function in 0..FUNCTIONS {
|
|
||||||
let address = (bus << 16) | (slot << 11) | (function << 8) | 0x8000_0000;
|
|
||||||
if read_offset(address, 0) == device_id {
|
|
||||||
return Some(read_device(address));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
fn read_device(address: u32) -> PciDevice {
|
|
||||||
let (device_id, vendor_id) = read_2_words(address, 0x00);
|
|
||||||
let (status, command) = read_2_words(address, 0x04);
|
|
||||||
let (base_class, sub_class, prog_if, revision_id) = read_4_bytes(address, 0x08);
|
|
||||||
let (bist, header_type, latency_timer, cache_line_size) = read_4_bytes(address, 0x0C);
|
|
||||||
let mut base_addresses = [0u32; 6];
|
|
||||||
base_addresses[0] = read_offset(address, 0x10);
|
|
||||||
base_addresses[1] = read_offset(address, 0x14);
|
|
||||||
base_addresses[2] = read_offset(address, 0x18);
|
|
||||||
base_addresses[3] = read_offset(address, 0x1C);
|
|
||||||
base_addresses[4] = read_offset(address, 0x20);
|
|
||||||
base_addresses[5] = read_offset(address, 0x24);
|
|
||||||
let cis = read_offset(address, 0x28);
|
|
||||||
let (sub_system_id, sub_vendor_id) = read_2_words(address, 0x2C);
|
|
||||||
let rom_base_address = read_offset(address, 0x30);
|
|
||||||
let mut reserved_2 = [0u32; 2];
|
|
||||||
reserved_2[0] = read_offset(address, 0x34);
|
|
||||||
reserved_2[1] = read_offset(address, 0x38);
|
|
||||||
let (maximum_latency, minimum_grant, interrupt_pin, interrupt_line) =
|
|
||||||
read_4_bytes(address, 0x3C);
|
|
||||||
|
|
||||||
PciDevice {
|
|
||||||
vendor_id,
|
|
||||||
device_id,
|
|
||||||
status,
|
|
||||||
command,
|
|
||||||
base_class,
|
|
||||||
sub_class,
|
|
||||||
prog_if,
|
|
||||||
revision_id,
|
|
||||||
bist,
|
|
||||||
header_type,
|
|
||||||
latency_timer,
|
|
||||||
cache_line_size,
|
|
||||||
base_addresses,
|
|
||||||
cis,
|
|
||||||
sub_system_id,
|
|
||||||
sub_vendor_id,
|
|
||||||
rom_base_address,
|
|
||||||
reserved_2,
|
|
||||||
maximum_latency,
|
|
||||||
minimum_grant,
|
|
||||||
interrupt_pin,
|
|
||||||
interrupt_line,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn read_2_words(address: u32, offset: u32) -> (u16, u16) {
|
|
||||||
let value = read_offset(address, offset);
|
|
||||||
let high_word = (value >> 16) as u16;
|
|
||||||
let low_word = value as u16;
|
|
||||||
(high_word, low_word)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn read_4_bytes(address: u32, offset: u32) -> (u8, u8, u8, u8) {
|
|
||||||
let value = read_offset(address, offset);
|
|
||||||
let high_word_high_byte = (value >> 24) as u8;
|
|
||||||
let high_word_low_byte = (value >> 16) as u8;
|
|
||||||
let low_word_high_byte = (value >> 8) as u8;
|
|
||||||
let low_wird_low_byte = value as u8;
|
|
||||||
(
|
|
||||||
high_word_high_byte,
|
|
||||||
high_word_low_byte,
|
|
||||||
low_word_high_byte,
|
|
||||||
low_wird_low_byte,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn read_offset(mut address: u32, offset: u32) -> u32 {
|
|
||||||
let mut config_address = Port::new(CONFIG_ADDRESS);
|
|
||||||
let mut data_address = Port::new(DATA_ADDRESS);
|
|
||||||
address |= offset & 0xFC;
|
|
||||||
unsafe {
|
|
||||||
config_address.write(address);
|
|
||||||
data_address.read()
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -11,33 +11,6 @@ use octant::Octant;
|
||||||
/// A point in 2D space.
|
/// A point in 2D space.
|
||||||
pub type Point<T> = (T, T);
|
pub type Point<T> = (T, T);
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone)]
|
|
||||||
pub struct Rectangle {
|
|
||||||
pub x: usize,
|
|
||||||
pub y: usize,
|
|
||||||
pub width: usize,
|
|
||||||
pub height: usize,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Rectangle {
|
|
||||||
pub fn new(x: usize, y: usize, width: usize, height: usize) -> Rectangle {
|
|
||||||
Rectangle {
|
|
||||||
x,
|
|
||||||
y,
|
|
||||||
width,
|
|
||||||
height,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn bottom(&self) -> usize {
|
|
||||||
self.y + self.height
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn right(&self) -> usize {
|
|
||||||
self.x + self.width
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) trait SignedNum: Signed + Ord + Copy + NumCast + NumAssignOps {
|
pub(crate) trait SignedNum: Signed + Ord + Copy + NumCast + NumAssignOps {
|
||||||
fn cast<T: NumCast>(value: T) -> Self {
|
fn cast<T: NumCast>(value: T) -> Self {
|
||||||
NumCast::from(value).unwrap()
|
NumCast::from(value).unwrap()
|
||||||
|
|
|
@ -7,9 +7,10 @@
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![warn(missing_docs)]
|
#![warn(missing_docs)]
|
||||||
|
|
||||||
|
extern crate alloc;
|
||||||
|
|
||||||
pub mod colors;
|
pub mod colors;
|
||||||
pub mod configurations;
|
pub mod configurations;
|
||||||
pub mod devices;
|
|
||||||
pub mod drawing;
|
pub mod drawing;
|
||||||
pub mod fonts;
|
pub mod fonts;
|
||||||
pub mod registers;
|
pub mod registers;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use super::{GraphicsWriter, Screen};
|
use super::{GraphicsWriter, Screen};
|
||||||
use crate::{
|
use crate::{
|
||||||
colors::DEFAULT_PALETTE,
|
colors::DEFAULT_PALETTE,
|
||||||
drawing::{Bresenham, Point, Rectangle},
|
drawing::{Bresenham, Point},
|
||||||
vga::{VideoMode, VGA},
|
vga::{VideoMode, VGA},
|
||||||
};
|
};
|
||||||
use font8x8::UnicodeFonts;
|
use font8x8::UnicodeFonts;
|
||||||
|
@ -47,20 +47,17 @@ impl GraphicsWriter<u8> for Graphics320x200x256 {
|
||||||
self.get_frame_buffer().write_bytes(color, Self::SIZE);
|
self.get_frame_buffer().write_bytes(color, Self::SIZE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_line(&self, start: Point<isize>, end: Point<isize>, color: u8) {
|
fn draw_line(&self, start: Point<isize>, end: Point<isize>, color: u8) {
|
||||||
for (x, y) in Bresenham::new(start, end) {
|
for (x, y) in Bresenham::new(start, end) {
|
||||||
self.set_pixel(x as usize, y as usize, color);
|
self.set_pixel(x as usize, y as usize, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_pixel(&self, x: usize, y: usize, color: u8) {
|
fn set_pixel(&self, x: usize, y: usize, color: u8) {
|
||||||
let offset = (y * WIDTH) + x;
|
let offset = (y * WIDTH) + x;
|
||||||
unsafe {
|
unsafe {
|
||||||
self.get_frame_buffer().add(offset).write_volatile(color);
|
self.get_frame_buffer().add(offset).write_volatile(color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_character(&self, x: usize, y: usize, character: char, color: u8) {
|
fn draw_character(&self, x: usize, y: usize, character: char, color: u8) {
|
||||||
let character = match font8x8::BASIC_FONTS.get(character) {
|
let character = match font8x8::BASIC_FONTS.get(character) {
|
||||||
Some(character) => character,
|
Some(character) => character,
|
||||||
|
@ -77,31 +74,7 @@ impl GraphicsWriter<u8> for Graphics320x200x256 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fn set_mode(&self) {
|
||||||
fn draw_rectangle(&self, rectangle: &Rectangle, color: u8) {
|
|
||||||
let p1 = (rectangle.x as isize, rectangle.y as isize);
|
|
||||||
let p2 = (rectangle.x as isize, rectangle.bottom() as isize);
|
|
||||||
let p3 = (rectangle.right() as isize, rectangle.bottom() as isize);
|
|
||||||
let p4 = (rectangle.right() as isize, rectangle.y as isize);
|
|
||||||
self.draw_line(p1, p2, color);
|
|
||||||
self.draw_line(p2, p3, color);
|
|
||||||
self.draw_line(p3, p4, color);
|
|
||||||
self.draw_line(p4, p1, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn draw_filled_rectangle(&self, rectangle: &Rectangle, color: u8) {
|
|
||||||
for y in rectangle.y..rectangle.bottom() {
|
|
||||||
for x in rectangle.x..rectangle.right() {
|
|
||||||
self.set_pixel(x as usize, y as usize, color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_frame_buffer(&self) -> *mut u8 {
|
|
||||||
u32::from(VGA.lock().get_frame_buffer()) as *mut u8
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_mode(&mut self) {
|
|
||||||
let mut vga = VGA.lock();
|
let mut vga = VGA.lock();
|
||||||
vga.set_video_mode(VideoMode::Mode320x200x256);
|
vga.set_video_mode(VideoMode::Mode320x200x256);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use super::{GraphicsWriter, Screen};
|
use super::{GraphicsWriter, Screen};
|
||||||
use crate::{
|
use crate::{
|
||||||
colors::DEFAULT_PALETTE,
|
colors::DEFAULT_PALETTE,
|
||||||
drawing::{Bresenham, Point, Rectangle},
|
drawing::{Bresenham, Point},
|
||||||
registers::PlaneMask,
|
registers::PlaneMask,
|
||||||
vga::{VideoMode, VGA},
|
vga::{VideoMode, VGA},
|
||||||
};
|
};
|
||||||
|
@ -52,13 +52,11 @@ impl GraphicsWriter<u8> for Graphics320x240x256 {
|
||||||
frame_buffer.write_bytes(color, Self::SIZE);
|
frame_buffer.write_bytes(color, Self::SIZE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_line(&self, start: Point<isize>, end: Point<isize>, color: u8) {
|
fn draw_line(&self, start: Point<isize>, end: Point<isize>, color: u8) {
|
||||||
for (x, y) in Bresenham::new(start, end) {
|
for (x, y) in Bresenham::new(start, end) {
|
||||||
self.set_pixel(x as usize, y as usize, color);
|
self.set_pixel(x as usize, y as usize, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_pixel(&self, x: usize, y: usize, color: u8) {
|
fn set_pixel(&self, x: usize, y: usize, color: u8) {
|
||||||
let frame_buffer = self.get_frame_buffer();
|
let frame_buffer = self.get_frame_buffer();
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -70,7 +68,6 @@ impl GraphicsWriter<u8> for Graphics320x240x256 {
|
||||||
frame_buffer.add(offset).write_volatile(color);
|
frame_buffer.add(offset).write_volatile(color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_character(&self, x: usize, y: usize, character: char, color: u8) {
|
fn draw_character(&self, x: usize, y: usize, character: char, color: u8) {
|
||||||
let character = match font8x8::BASIC_FONTS.get(character) {
|
let character = match font8x8::BASIC_FONTS.get(character) {
|
||||||
Some(character) => character,
|
Some(character) => character,
|
||||||
|
@ -87,31 +84,7 @@ impl GraphicsWriter<u8> for Graphics320x240x256 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fn set_mode(&self) {
|
||||||
fn draw_rectangle(&self, rectangle: &Rectangle, color: u8) {
|
|
||||||
let p1 = (rectangle.x as isize, rectangle.y as isize);
|
|
||||||
let p2 = (rectangle.x as isize, rectangle.bottom() as isize);
|
|
||||||
let p3 = (rectangle.right() as isize, rectangle.bottom() as isize);
|
|
||||||
let p4 = (rectangle.right() as isize, rectangle.y as isize);
|
|
||||||
self.draw_line(p1, p2, color);
|
|
||||||
self.draw_line(p2, p3, color);
|
|
||||||
self.draw_line(p3, p4, color);
|
|
||||||
self.draw_line(p4, p1, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn draw_filled_rectangle(&self, rectangle: &Rectangle, color: u8) {
|
|
||||||
for y in rectangle.y..rectangle.bottom() {
|
|
||||||
for x in rectangle.x..rectangle.right() {
|
|
||||||
self.set_pixel(x as usize, y as usize, color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_frame_buffer(&self) -> *mut u8 {
|
|
||||||
u32::from(VGA.lock().get_frame_buffer()) as *mut u8
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_mode(&mut self) {
|
|
||||||
let mut vga = VGA.lock();
|
let mut vga = VGA.lock();
|
||||||
vga.set_video_mode(VideoMode::Mode320x240x256);
|
vga.set_video_mode(VideoMode::Mode320x240x256);
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
use super::{GraphicsWriter, Screen};
|
use super::{GraphicsWriter, Screen};
|
||||||
use crate::{
|
use crate::{
|
||||||
colors::{Color16, DEFAULT_PALETTE},
|
colors::{Color16, DEFAULT_PALETTE},
|
||||||
drawing::{Bresenham, Point, Rectangle},
|
drawing::{Bresenham, Point},
|
||||||
registers::{PlaneMask, WriteMode},
|
registers::{PlaneMask, WriteMode},
|
||||||
vga::{VideoMode, VGA},
|
vga::{VideoMode, VGA},
|
||||||
};
|
};
|
||||||
|
use core::convert::From;
|
||||||
use font8x8::UnicodeFonts;
|
use font8x8::UnicodeFonts;
|
||||||
|
|
||||||
const WIDTH: usize = 640;
|
const WIDTH: usize = 640;
|
||||||
|
@ -77,25 +78,6 @@ impl GraphicsWriter<Color16> for Graphics640x480x16 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_rectangle(&self, rectangle: &Rectangle, color: Color16) {
|
|
||||||
let p1 = (rectangle.x as isize, rectangle.y as isize);
|
|
||||||
let p2 = (rectangle.x as isize, rectangle.bottom() as isize);
|
|
||||||
let p3 = (rectangle.right() as isize, rectangle.bottom() as isize);
|
|
||||||
let p4 = (rectangle.right() as isize, rectangle.y as isize);
|
|
||||||
self.draw_line(p1, p2, color);
|
|
||||||
self.draw_line(p2, p3, color);
|
|
||||||
self.draw_line(p3, p4, color);
|
|
||||||
self.draw_line(p4, p1, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn draw_filled_rectangle(&self, rectangle: &Rectangle, color: Color16) {
|
|
||||||
for y in rectangle.y..rectangle.bottom() {
|
|
||||||
for x in rectangle.x..rectangle.right() {
|
|
||||||
self.set_pixel(x as usize, y as usize, color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// **Note:** This method is provided for convenience, but has terrible
|
/// **Note:** This method is provided for convenience, but has terrible
|
||||||
/// performance since it needs to ensure the correct `WriteMode` per pixel
|
/// performance since it needs to ensure the correct `WriteMode` per pixel
|
||||||
/// drawn. If you need to draw more then one pixel, consider using a method
|
/// drawn. If you need to draw more then one pixel, consider using a method
|
||||||
|
@ -105,11 +87,7 @@ impl GraphicsWriter<Color16> for Graphics640x480x16 {
|
||||||
self._set_pixel(x, y, color);
|
self._set_pixel(x, y, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_frame_buffer(&self) -> *mut Color16 {
|
fn set_mode(&self) {
|
||||||
u32::from(VGA.lock().get_frame_buffer()) as *mut Color16
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_mode(&mut self) {
|
|
||||||
let mut vga = VGA.lock();
|
let mut vga = VGA.lock();
|
||||||
vga.set_video_mode(VideoMode::Mode640x480x16);
|
vga.set_video_mode(VideoMode::Mode640x480x16);
|
||||||
|
|
||||||
|
@ -145,6 +123,7 @@ impl Graphics640x480x16 {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn _set_pixel(self, x: usize, y: usize, color: Color16) {
|
fn _set_pixel(self, x: usize, y: usize, color: Color16) {
|
||||||
|
if x < 640 && y < 480 {
|
||||||
let frame_buffer = self.get_frame_buffer();
|
let frame_buffer = self.get_frame_buffer();
|
||||||
let offset = x / 8 + y * WIDTH_IN_BYTES;
|
let offset = x / 8 + y * WIDTH_IN_BYTES;
|
||||||
let pixel_mask = 0x80 >> (x & 0x07);
|
let pixel_mask = 0x80 >> (x & 0x07);
|
||||||
|
@ -153,7 +132,80 @@ impl Graphics640x480x16 {
|
||||||
.set_bit_mask(pixel_mask);
|
.set_bit_mask(pixel_mask);
|
||||||
unsafe {
|
unsafe {
|
||||||
frame_buffer.add(offset).read_volatile();
|
frame_buffer.add(offset).read_volatile();
|
||||||
frame_buffer.add(offset).write_volatile(color);
|
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,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ mod text_80x25;
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
colors::{Color16, TextModeColor},
|
colors::{Color16, TextModeColor},
|
||||||
drawing::{Point, Rectangle},
|
drawing::Point,
|
||||||
registers::CrtcControllerIndex,
|
registers::CrtcControllerIndex,
|
||||||
vga::{Vga, VGA},
|
vga::{Vga, VGA},
|
||||||
};
|
};
|
||||||
|
@ -195,14 +195,12 @@ pub trait GraphicsWriter<Color> {
|
||||||
fn draw_line(&self, start: Point<isize>, end: Point<isize>, color: Color);
|
fn draw_line(&self, start: Point<isize>, end: Point<isize>, color: Color);
|
||||||
/// Draws a character at the given `(x, y)` coordinant to the specified `color`.
|
/// Draws a character at the given `(x, y)` coordinant to the specified `color`.
|
||||||
fn draw_character(&self, x: usize, y: usize, character: char, color: Color);
|
fn draw_character(&self, x: usize, y: usize, character: char, color: Color);
|
||||||
/// Draws a rectangle using the given `rectangle` and `color`.
|
|
||||||
fn draw_rectangle(&self, rectangle: &Rectangle, color: Color);
|
|
||||||
/// Draws a filled rectangle using the given `rectangle` and `color`.
|
|
||||||
fn draw_filled_rectangle(&self, rectangle: &Rectangle, color: Color);
|
|
||||||
/// Sets the given pixel at `(x, y)` to the given `color`.
|
/// Sets the given pixel at `(x, y)` to the given `color`.
|
||||||
fn set_pixel(&self, x: usize, y: usize, color: Color);
|
fn set_pixel(&self, x: usize, y: usize, color: Color);
|
||||||
/// Returns the frame buffer for this vga mode.
|
|
||||||
fn get_frame_buffer(&self) -> *mut Color;
|
|
||||||
/// Sets the graphics device to a `VideoMode`.
|
/// Sets the graphics device to a `VideoMode`.
|
||||||
fn set_mode(&mut self);
|
fn set_mode(&self);
|
||||||
|
/// Returns the frame buffer for this vga mode.
|
||||||
|
fn get_frame_buffer(&self) -> *mut u8 {
|
||||||
|
u32::from(VGA.lock().get_frame_buffer()) as *mut u8
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,13 +5,13 @@ authors = ["Ryan Kennedy <rkennedy9064@gmail.com>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bootloader = { version = "0.9.0", features = ["map_physical_memory"] }
|
bootloader = { version = "0.9.11", features = ["map_physical_memory"] }
|
||||||
conquer-once = { version = "0.2.0", default-features = false }
|
conquer-once = { version = "0.3.2", default-features = false }
|
||||||
spinning_top = { version = "0.1.0", features = ["nightly"] }
|
spinning_top = { version = "0.2.4", features = ["nightly"] }
|
||||||
pic8259_simple = "0.1.1"
|
pic8259 = "0.10.1"
|
||||||
vga = { path = "../" }
|
vga = { path = "../" }
|
||||||
uart_16550 = "0.2.4"
|
uart_16550 = "0.2.14"
|
||||||
x86_64 = "0.9.6"
|
x86_64 = "0.14.2"
|
||||||
|
|
||||||
[package.metadata.bootimage]
|
[package.metadata.bootimage]
|
||||||
test-args = [
|
test-args = [
|
||||||
|
|
|
@ -2,7 +2,7 @@ use crate::gdt;
|
||||||
use crate::{hlt_loop, serial_print, serial_println};
|
use crate::{hlt_loop, serial_print, serial_println};
|
||||||
use conquer_once::spin::Lazy;
|
use conquer_once::spin::Lazy;
|
||||||
use core::convert::Into;
|
use core::convert::Into;
|
||||||
use pic8259_simple::ChainedPics;
|
use pic8259::ChainedPics;
|
||||||
use spinning_top::Spinlock;
|
use spinning_top::Spinlock;
|
||||||
use x86_64::structures::idt::{InterruptDescriptorTable, InterruptStackFrame, PageFaultErrorCode};
|
use x86_64::structures::idt::{InterruptDescriptorTable, InterruptStackFrame, PageFaultErrorCode};
|
||||||
|
|
||||||
|
@ -49,14 +49,14 @@ pub fn init_idt() {
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "x86-interrupt" fn double_fault_handler(
|
extern "x86-interrupt" fn double_fault_handler(
|
||||||
stack_frame: &mut InterruptStackFrame,
|
stack_frame: InterruptStackFrame,
|
||||||
_error_code: u64,
|
_error_code: u64,
|
||||||
) -> ! {
|
) -> ! {
|
||||||
panic!("EXCEPTION: DOUBLE FAULT\n{:#?}", stack_frame);
|
panic!("EXCEPTION: DOUBLE FAULT\n{:#?}", stack_frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "x86-interrupt" fn page_fault_handler(
|
extern "x86-interrupt" fn page_fault_handler(
|
||||||
stack_frame: &mut InterruptStackFrame,
|
stack_frame: InterruptStackFrame,
|
||||||
error_code: PageFaultErrorCode,
|
error_code: PageFaultErrorCode,
|
||||||
) {
|
) {
|
||||||
use x86_64::registers::control::Cr2;
|
use x86_64::registers::control::Cr2;
|
||||||
|
@ -69,7 +69,7 @@ extern "x86-interrupt" fn page_fault_handler(
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "x86-interrupt" fn segment_not_present(
|
extern "x86-interrupt" fn segment_not_present(
|
||||||
_stack_frame: &mut InterruptStackFrame,
|
_stack_frame: InterruptStackFrame,
|
||||||
_error_code: u64,
|
_error_code: u64,
|
||||||
) {
|
) {
|
||||||
// For some reason this sometimes gets thrown when running tests in qemu,
|
// For some reason this sometimes gets thrown when running tests in qemu,
|
||||||
|
|
Loading…
Reference in a new issue