juls0730

Untitled

Jun 19th, 2023
3,413
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.69 KB | Source Code | 0 0
  1. #![no_std]
  2. #![no_main]
  3.  
  4. mod drivers;
  5. mod libs;
  6.  
  7. use core::panic::PanicInfo;
  8. use drivers::serial;
  9.  
  10. const VGA_BUFFER: *mut u8 = 0xA0000 as *mut u8;
  11.  
  12. #[no_mangle]
  13. pub extern "C" fn _start() -> ! {
  14.     serial::init_serial();
  15.  
  16.     let message = b"Hello world\n";
  17.  
  18.     for (i, &byte) in message.iter().enumerate() {
  19.         serial::write_serial(byte);
  20.     }
  21.  
  22.     for y in 0..=479 {
  23.         for x in 0..=639 {
  24.             put_pixel(x, y, 1);
  25.         }
  26.     }
  27.  
  28.     loop {}
  29. }
  30.  
  31. fn put_pixel(pos_x: usize, pos_y: usize, vga_color: u8) {
  32.     unsafe {
  33.         let location = VGA_BUFFER.offset((640 * pos_y + pos_x) as isize);
  34.         *location = vga_color;
  35.     }
  36. }
  37.  
  38. #[panic_handler]
  39. fn panic (_info: &PanicInfo) -> ! {
  40.     loop {}
  41. }
Advertisement
Add Comment
Please, Sign In to add comment