Skip to content

Commit a07822a

Browse files
committed
x86_64: fix for real hardware. remove legacy drivers.
1 parent 590df84 commit a07822a

File tree

10 files changed

+45
-186
lines changed

10 files changed

+45
-186
lines changed

kernel/Cargo.lock

Lines changed: 24 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

kernel/Cargo.toml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ buddy_system_allocator = "0.3"
5858
pci = { git = "https://github.com/rcore-os/pci-rs" }
5959
device_tree = { git = "https://github.com/rcore-os/device_tree-rs" }
6060
isomorphic_drivers = { git = "https://github.com/rcore-os/isomorphic_drivers", features = ["log"] }
61-
lazy_static = { version = "1.3", features = ["spin_no_std"] }
61+
lazy_static = { version = "1.4", features = ["spin_no_std"] }
6262
smoltcp = { git = "https://github.com/rcore-os/smoltcp", default-features = false, features = ["alloc", "log", "proto-ipv4", "proto-igmp", "socket-icmp", "socket-udp", "socket-tcp", "socket-raw"] }
6363
bitmap-allocator = { git = "https://github.com/rcore-os/bitmap-allocator" }
64-
rcore-console = { git = "https://github.com/rcore-os/rcore-console", rev = "323c176", default-features = false }
64+
rcore-console = { git = "https://github.com/rcore-os/rcore-console", rev = "b7bacf9", default-features = false }
6565
rcore-memory = { path = "../crate/memory" }
6666
rcore-thread = { git = "https://github.com/rcore-os/rcore-thread" }
6767
rcore-fs = { git = "https://github.com/rcore-os/rcore-fs", rev = "33f86c47" }
@@ -76,7 +76,7 @@ compression = { version = "0.1.4", default-features = false, features = ["gzip"]
7676
rboot = { path = "../rboot" }
7777
apic = { git = "https://github.com/rcore-os/apic-rs" }
7878
x86_64 = "0.7"
79-
raw-cpuid = "6.0"
79+
raw-cpuid = "7.0"
8080
uart_16550 = "0.2"
8181
pc-keyboard = "0.5"
8282
acpi = "0.4"
@@ -94,10 +94,5 @@ bcm2837 = { git = "https://github.com/rcore-os/bcm2837", version = "2.1.0", opti
9494
mips = "^0.2.0"
9595
paste = "0.1"
9696

97-
[package.metadata.bootimage]
98-
default-target = "targets/x86_64.json"
99-
output = "target/x86_64/bootimage.bin"
100-
minimum-image-size = 0 # The minimum output file size (in MiB)
101-
10297
[build-dependencies]
10398
cc = "1.0"

kernel/src/arch/x86_64/driver/mod.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
11
pub mod ide;
22
pub mod keyboard;
3-
pub mod pic;
4-
pub mod pit;
53
pub mod rtc_cmos;
64
pub mod serial;
75

86
use super::BootInfo;
97

108
pub fn init(boot_info: &BootInfo) {
11-
// Use IOAPIC instead of PIC
12-
pic::disable();
13-
14-
// Use APIC Timer instead of PIT
15-
// pit::init();
16-
179
serial::init();
1810
keyboard::init();
1911

@@ -30,6 +22,9 @@ pub fn init(boot_info: &BootInfo) {
3022
enable_irq(consts::PIRQG);
3123
enable_irq(consts::PIRQH);
3224
*/
25+
}
26+
27+
pub fn init_graphic(boot_info: &BootInfo) {
3328
super::board::init_driver(boot_info);
3429
crate::drivers::console::init();
3530
}

kernel/src/arch/x86_64/driver/pic.rs

Lines changed: 0 additions & 100 deletions
This file was deleted.

kernel/src/arch/x86_64/driver/pit.rs

Lines changed: 0 additions & 43 deletions
This file was deleted.

kernel/src/arch/x86_64/io.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ pub fn getchar() -> char {
1111

1212
pub fn putfmt(fmt: Arguments) {
1313
// output to serial
14-
unsafe {
15-
COM1.force_unlock();
14+
#[cfg(not(feature = "board_pc"))]
15+
{
16+
unsafe {
17+
COM1.force_unlock();
18+
}
19+
COM1.lock().write_fmt(fmt).unwrap();
1620
}
17-
COM1.lock().write_fmt(fmt).unwrap();
1821

1922
// print to graphic
2023
#[cfg(feature = "consolegraphic")]

kernel/src/arch/x86_64/memory.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
use super::paging::PageTableImpl;
2-
use crate::memory::{init_heap, FRAME_ALLOCATOR};
2+
use crate::memory::FRAME_ALLOCATOR;
33
use bitmap_allocator::BitAlloc;
44
use rboot::{BootInfo, MemoryType};
55
use rcore_memory::paging::*;
66
use rcore_memory::PAGE_SIZE;
77

88
pub fn init(boot_info: &BootInfo) {
99
init_frame_allocator(boot_info);
10-
init_heap();
1110
info!("memory: init end");
1211
}
1312

kernel/src/arch/x86_64/mod.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ static AP_CAN_INIT: AtomicBool = AtomicBool::new(false);
2222

2323
/// The entry point of kernel
2424
#[no_mangle] // don't mangle the name of this function
25-
pub extern "C" fn _start(boot_info: *const BootInfo) -> ! {
25+
pub extern "C" fn _start(boot_info: &'static BootInfo) -> ! {
2626
let cpu_id = cpu::id();
2727
println!("Hello world! from CPU {}!", cpu_id);
2828

@@ -33,11 +33,12 @@ pub extern "C" fn _start(boot_info: *const BootInfo) -> ! {
3333
other_start();
3434
}
3535

36-
// First init log mod, so that we can print log info.
36+
// init log, heap and graphic output
3737
crate::logging::init();
38+
crate::memory::init_heap();
39+
driver::init_graphic(boot_info);
3840

3941
// check BootInfo from bootloader
40-
let boot_info = unsafe { &*boot_info };
4142
info!("{:#x?}", boot_info);
4243
assert_eq!(
4344
boot_info.physical_memory_offset as usize,
@@ -47,11 +48,9 @@ pub extern "C" fn _start(boot_info: *const BootInfo) -> ! {
4748
// setup fast syscall in x86_64
4849
interrupt::fast_syscall::init();
4950

50-
// Init physical memory management and heap.
51+
// Init physical memory management
5152
memory::init(boot_info);
5253

53-
// Now heap is available
54-
5554
// Init GDT
5655
gdt::init();
5756
// Init trap handling

kernel/src/drivers/gpu/fb.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,9 @@ impl Drawing<Rgb888> for Framebuffer {
260260
where
261261
T: IntoIterator<Item = Pixel<Rgb888>>,
262262
{
263-
for Pixel(coord, color) in item {
263+
for Pixel(point, color) in item {
264264
let pixel = color.pack32(self.fb_info.format);
265-
self.write(coord[0], coord[1], pixel);
265+
self.write(point[0] as u32, point[1] as u32, pixel);
266266
}
267267
}
268268
}

rboot

0 commit comments

Comments
 (0)