Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a test OS #159

Draft
wants to merge 122 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
565b4cc
Add the test project
toku-sa-n Nov 25, 2023
fca5847
Add the build target config
toku-sa-n Nov 25, 2023
5f1b8ba
Add the cargo config
toku-sa-n Nov 25, 2023
b1936d6
Fix the path
toku-sa-n Nov 25, 2023
9e7c558
Rename
toku-sa-n Nov 25, 2023
0f140c3
Typo
toku-sa-n Nov 25, 2023
f12c681
Build an UEFI image
toku-sa-n Nov 25, 2023
a3f5240
Add a `Makefile`
toku-sa-n Nov 27, 2023
85c105f
Ignores
toku-sa-n Nov 27, 2023
073688c
No reboot
toku-sa-n Nov 27, 2023
d5978b2
Introduce variables to `Makefile`
toku-sa-n Nov 27, 2023
d2c72e0
Printing
toku-sa-n Nov 27, 2023
bad6352
Search a xHC
toku-sa-n Nov 30, 2023
dc536d2
Remove an unused import
toku-sa-n Nov 30, 2023
1088aa4
Iterator
toku-sa-n Nov 30, 2023
b701c16
Access to registers
toku-sa-n Dec 4, 2023
259bea8
Merge branch 'main' into test_os
toku-sa-n Dec 4, 2023
0769f55
Iterate extended capabilities
toku-sa-n Dec 4, 2023
ee69a5f
Singleton
toku-sa-n Dec 4, 2023
3bfa05d
Merge branch 'main' into test_os
toku-sa-n Dec 7, 2023
a73c342
Merge branch 'main' into test_os
toku-sa-n Dec 10, 2023
136c536
Merge branch 'test_os' of github.com:toku-sa-n/xhci into test_os
toku-sa-n Dec 10, 2023
fc2ae1f
Workspace
toku-sa-n Dec 10, 2023
ad7fa52
Initialize xHC
toku-sa-n Dec 10, 2023
f62994f
Allocator
toku-sa-n Dec 10, 2023
fbb855d
Doc
toku-sa-n Dec 11, 2023
c52fc4d
Allocate rings
toku-sa-n Dec 11, 2023
eb6c038
Event rings
toku-sa-n Dec 12, 2023
d424303
Minimum is defined
toku-sa-n Dec 12, 2023
54e7363
Command ring
toku-sa-n Dec 12, 2023
f145205
DCBAA
toku-sa-n Dec 12, 2023
7db9ad8
Scratchpad
toku-sa-n Dec 12, 2023
cbdfb92
Run
toku-sa-n Dec 12, 2023
cb14395
No static just a test
toku-sa-n Dec 12, 2023
9c0bf6e
No static register
toku-sa-n Dec 12, 2023
66df7f0
Unsafenize
toku-sa-n Dec 12, 2023
280510a
No static
toku-sa-n Dec 13, 2023
efd9ed0
Init
toku-sa-n Dec 13, 2023
ee59722
No static
toku-sa-n Dec 13, 2023
70e1ed8
No static
toku-sa-n Dec 13, 2023
728be74
In struct
toku-sa-n Dec 13, 2023
b4160b9
Split
toku-sa-n Dec 13, 2023
31bf3db
Op
toku-sa-n Dec 13, 2023
5f9b127
Fix
toku-sa-n Dec 13, 2023
4c77b47
Fix
toku-sa-n Dec 13, 2023
2641cb5
Split
toku-sa-n Dec 13, 2023
508119a
Remove
toku-sa-n Dec 13, 2023
4324d5c
Read
toku-sa-n Dec 13, 2023
9452de7
Fix the number of rings
toku-sa-n Dec 13, 2023
056c6d7
Fix
toku-sa-n Dec 13, 2023
fcd1aea
Template
toku-sa-n Dec 13, 2023
10b7ec7
Add a mouse
toku-sa-n Dec 13, 2023
4c2b5ea
Reset a port
toku-sa-n Dec 13, 2023
02b7d4d
Exec a no-op
toku-sa-n Dec 14, 2023
923fcb7
Implementing
toku-sa-n Dec 15, 2023
e002760
Add a README
toku-sa-n Dec 15, 2023
ae6a78f
Doc
toku-sa-n Dec 15, 2023
3346d3a
Docs
toku-sa-n Dec 15, 2023
e288ec4
README
toku-sa-n Dec 15, 2023
d3ec6ce
Comment
toku-sa-n Dec 16, 2023
22df3d4
Comment
toku-sa-n Dec 16, 2023
1210635
Docs
toku-sa-n Dec 17, 2023
6b195bc
Docs
toku-sa-n Dec 17, 2023
1f1ac75
README
toku-sa-n Dec 17, 2023
64cd674
Follow the spec
toku-sa-n Dec 17, 2023
8340735
Add the `all` target
toku-sa-n Dec 18, 2023
3d55f85
Shared ref
toku-sa-n Dec 18, 2023
69a6a0e
Shared ref
toku-sa-n Dec 18, 2023
930c4b5
No parameter
toku-sa-n Dec 18, 2023
b8162c4
Shared ref
toku-sa-n Dec 18, 2023
47b3973
Shared
toku-sa-n Dec 18, 2023
ab4f332
Shared ref
toku-sa-n Dec 18, 2023
26b1a2f
Shared
toku-sa-n Dec 18, 2023
102fda9
Shared
toku-sa-n Dec 18, 2023
48bda5e
Shared
toku-sa-n Dec 18, 2023
6489084
Polling
toku-sa-n Dec 18, 2023
28fc89c
Process immediately
toku-sa-n Dec 18, 2023
3f4614c
Shared
toku-sa-n Dec 18, 2023
09c5b1b
Fix the makefile
toku-sa-n Dec 18, 2023
9cf7bb0
Doing
toku-sa-n Dec 18, 2023
1f1467b
Doing
toku-sa-n Dec 18, 2023
b25e983
I love static
toku-sa-n Dec 18, 2023
d1ab860
Static command
toku-sa-n Dec 18, 2023
b104a75
Static event
toku-sa-n Dec 18, 2023
1908ee4
Static
toku-sa-n Dec 18, 2023
93a5fb8
Fix
toku-sa-n Dec 19, 2023
bd053c4
Doing
toku-sa-n Dec 19, 2023
001b2c8
Doing
toku-sa-n Dec 19, 2023
2549827
Doing
toku-sa-n Dec 19, 2023
f3c0569
This code is taken from my ramen OS
toku-sa-n Dec 19, 2023
c3a468c
Do not print
toku-sa-n Dec 19, 2023
1c4d776
Copy code from my Ramen OS because I'm very tired.
toku-sa-n Dec 19, 2023
831075b
Logger
toku-sa-n Dec 19, 2023
069e011
Split
toku-sa-n Dec 19, 2023
1c8a52a
Remove license comments
toku-sa-n Dec 19, 2023
debc038
Init allocators
toku-sa-n Dec 19, 2023
bf1d089
Log everything
toku-sa-n Dec 19, 2023
354dabf
Log everything
toku-sa-n Dec 19, 2023
a1e71fd
Assert the existence of xHC
toku-sa-n Dec 19, 2023
8b9f5e5
Use underscore
toku-sa-n Dec 19, 2023
d126005
Docs
toku-sa-n Dec 19, 2023
ca63ef8
Ownership
toku-sa-n Dec 19, 2023
f59d93a
Static
toku-sa-n Dec 19, 2023
56ad667
Static
toku-sa-n Dec 19, 2023
e08269d
Doc
toku-sa-n Dec 19, 2023
d10ebe5
Docs
toku-sa-n Dec 19, 2023
6829f53
Page box
toku-sa-n Dec 19, 2023
e970dd9
Fix
toku-sa-n Dec 19, 2023
82b4f8e
DCBAA
toku-sa-n Dec 19, 2023
e0839b8
Rename
toku-sa-n Dec 19, 2023
61fdd25
Scratchpad
toku-sa-n Dec 19, 2023
a8fcc49
?
toku-sa-n Dec 19, 2023
4024e6d
Fix the len
toku-sa-n Dec 19, 2023
5519b62
Fix
toku-sa-n Dec 19, 2023
f274585
Use `BTreeSet`
toku-sa-n Dec 19, 2023
11afe3a
Noop
toku-sa-n Dec 19, 2023
af312fb
success
toku-sa-n Dec 19, 2023
1c0c660
Exit
toku-sa-n Dec 19, 2023
e805a9a
Merge branch 'main' into test_os
toku-sa-n Dec 20, 2023
34f5837
Merge branch 'main' into test_os
toku-sa-n Dec 20, 2023
37bb4b8
Format
toku-sa-n Dec 20, 2023
fc9360f
Merge branch 'test_os' of github.com:toku-sa-n/xhci into test_os
toku-sa-n Dec 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Shared
  • Loading branch information
toku-sa-n committed Dec 18, 2023
commit 48bda5e2907b7bcf7680387fe88f1d3c130b4ed8
3 changes: 1 addition & 2 deletions test/src/command_ring.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use core::cell::RefCell;

use crate::{event::EventHandler, registers::Registers};
use alloc::{boxed::Box, rc::Rc};
use core::cell::RefCell;
use xhci::ring::trb::{
self, command,
event::{CommandCompletion, CompletionCode},
Expand Down
17 changes: 2 additions & 15 deletions test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ mod xhc;
use core::cell::RefCell;

use alloc::rc::Rc;
use command_ring::CommandRingController;
use dcbaa::DeviceContextBaseAddressArray;
use event::EventHandler;
use qemu_exit::QEMUExit;
use qemu_print::qemu_println;
use uefi::table::boot::MemoryType;
Expand All @@ -32,19 +29,9 @@ fn main(image: uefi::Handle, st: uefi::table::SystemTable<uefi::table::Boot>) ->

// SAFETY: We are calling `get_accessor()` only once.
let regs = unsafe { registers::get_accessor() };
let mut regs = Rc::new(RefCell::new(regs));
let regs = Rc::new(RefCell::new(regs));

xhc::init(&mut regs.borrow_mut());

let mut event_handler = EventHandler::new(&mut regs.borrow_mut());
let mut event_handler = Rc::new(RefCell::new(event_handler));
let mut command_ring = CommandRingController::new(&mut regs, &event_handler);

let _ = DeviceContextBaseAddressArray::new(&mut regs.borrow_mut());
scratchpat::init(&regs.borrow());

xhc::run(&mut regs.borrow_mut().operational);
xhc::ensure_no_error_occurs(&regs.borrow().operational.usbsts.read_volatile());
let (event_handler, mut command_ring, _) = xhc::init(&regs);

command_ring.send_nop();

Expand Down
32 changes: 28 additions & 4 deletions test/src/xhc.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,50 @@
use crate::command_ring::CommandRingController;
use crate::dcbaa::DeviceContextBaseAddressArray;
use crate::event::EventHandler;
use crate::mapper::Mapper;
use crate::registers::Registers;
use crate::scratchpat;
use alloc::rc::Rc;
use core::cell::RefCell;
use qemu_print::qemu_println;
use xhci::registers::operational::UsbStatusRegister;
use xhci::registers::Operational;

pub fn init(regs: &mut Registers) {
pub fn init(
regs: &Rc<RefCell<Registers>>,
) -> (
Rc<RefCell<EventHandler>>,
CommandRingController,
DeviceContextBaseAddressArray,
) {
qemu_println!("Initializing xHC...");

Initializer::new(regs).init();
Initializer::new(&mut regs.borrow_mut()).init();

let event_handler = EventHandler::new(&mut regs.borrow_mut());
let event_handler = Rc::new(RefCell::new(event_handler));
let command_ring = CommandRingController::new(&regs, &event_handler);

let dcbaa = DeviceContextBaseAddressArray::new(&mut regs.borrow_mut());
scratchpat::init(&regs.borrow());

run(&mut regs.borrow_mut().operational);
ensure_no_error_occurs(&regs.borrow().operational.usbsts.read_volatile());

qemu_println!("xHC is initialized.");

(event_handler, command_ring, dcbaa)
}

pub fn run(op: &mut Operational<Mapper>) {
fn run(op: &mut Operational<Mapper>) {
op.usbcmd.update_volatile(|u| {
u.set_run_stop();
});

while op.usbsts.read_volatile().hc_halted() {}
}

pub fn ensure_no_error_occurs(s: &UsbStatusRegister) {
fn ensure_no_error_occurs(s: &UsbStatusRegister) {
assert!(!s.hc_halted(), "HC is halted.");
assert!(
!s.host_system_error(),
Expand Down