You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: main.rs
    path of file: ./repos/mandarin/kernel/src
    
    the code of the file until where you have to start completion: #![no_std]
#![no_main]
#![feature(asm)]
#![feature(custom_test_frameworks)]
#![feature(const_maybe_uninit_assume_init)]
#![test_runner(test_runner)]
#![reexport_test_harness_main = "test_main"]

#[macro_use]
mod console;

#[macro_use]
mod utils;

mod global;
mod graphics;
mod pci;
mod sync;
mod usb;
mod x86;

fn switch_ehci_to_xhci(xhc_dev: &pci::Device) {
    trace!("switch_ehci_to_xhci");

    let mut intel_ehc_exist = false;
    for dev in pci::devices() {
        let ehci = matches!(dev.as_config().read_class_code(), (0x0C, 0x03,
    
pub extern "C" fn kernel_main(frame_buffer: FrameBuffer) {
    let w = frame_buffer.width();
    let h = frame_buffer.height();
    global::init_frame_buffer(frame_buffer);

    use graphics::{Color, Render};
    global::lock_frame_buffer(|fb| fb.draw_filled_rect(0, 0, w, h, Color::BLACK));

    use graphics::font::{Font, ShinonomeFont};
    let (cw, ch) = ShinonomeFont.char_size(' ');
    let columns = (w / cw) as usize;
    let lines = (h / ch) as usize;
    global::init_console(columns, lines);

    #[cfg(test)]
    test_main();

    print!(
        r"
 __  __                 _            _          ___  ____
|  \/  | __ _ _ __   __| | __ _ _ __(_)_ __    / _ \/ ___| 
| |\/| |/ _` | '_ \ / _` |/ _` | '__| | '_ \  | | | \___ \ 
| |  | | (_| | | | | (_| | (_| | |  | | | | | | |_| |___) |
|_|  |_|\__,_|_| |_|\__,_|\__,_|_|  |_|_| |_|  \___/|____/ 
"
    );
    println!();

    unsafe { pci::scan_all_buses() }.expect("Failed to scan PCI bus");

    for dev in pci::devices().iter() {
        trace!("{:?}", dev);
    }

    let mut xhc_dev: Option<&pci::Device> = None;
    for dev in pci::devices().iter() {
        let config = dev.as_config();
        // looking for xHC device
        if let (0x0C, 0x03, 0x30, _) = config.read_class_code() {
            xhc_dev = Some(dev);
            // prioritize intel's one
            if config.read_vendor_id() == 0x8086 {
                break;
            }
        }
    }
    match xhc_dev {
        Some(dev) => {
            if dev.as_config().read_vendor_id() == 0x8086 {
                switch_ehci_to_xhci(dev);
            }

            debug!("xHC found: {:?}", dev);
            let xhc_bar = dev.read_bar(0);
            debug!("Read BAR: {:?}", xhc_bar);
            let mmio_base = (xhc_bar.unwrap() & !0x0F) as usize;
            debug!("MMIO base: {:8x}", mmio_base);

            let mut controller = unsafe { usb::xhci::Controller::new(mmio_base).unwrap() };
            debug!("xHC initialized");

            controller.run();
            controller.configure_ports();

            loop {
                if let Err(e) = controller.process_event() {
                    error!("Error occurs during process_event: {:?}", e);
                }
            }
        }
        None => {
            error!("xHC not found");
        }
    }

    loop {
        x86::hlt();
    }
}