|
| 1 | +use core::ptr; |
1 | 2 | use uefi::proto::console::gop::{BltOp, BltPixel, GraphicsOutput, PixelFormat};
|
2 | 3 | use uefi::table::boot::BootServices;
|
3 | 4 | use uefi_exts::BootServicesExt;
|
@@ -54,14 +55,20 @@ fn draw_fb(gop: &mut GraphicsOutput) {
|
54 | 55 |
|
55 | 56 | type PixelWriter<'a> = &'a Fn(&mut [u8], (u8, u8, u8));
|
56 | 57 | let write_pixel_rgb = |pixel: &mut [u8], (r, g, b)| {
|
57 |
| - pixel[0] = r; |
58 |
| - pixel[1] = g; |
59 |
| - pixel[2] = b; |
| 58 | + let p = pixel.as_mut_ptr(); |
| 59 | + unsafe { |
| 60 | + ptr::write_volatile(p.offset(0), r); |
| 61 | + ptr::write_volatile(p.offset(1), g); |
| 62 | + ptr::write_volatile(p.offset(2), b); |
| 63 | + } |
60 | 64 | };
|
61 | 65 | let write_pixel_bgr = |pixel: &mut [u8], (r, g, b)| {
|
62 |
| - pixel[0] = b; |
63 |
| - pixel[1] = g; |
64 |
| - pixel[2] = r; |
| 66 | + let p = pixel.as_mut_ptr(); |
| 67 | + unsafe { |
| 68 | + ptr::write_volatile(p.offset(0), b); |
| 69 | + ptr::write_volatile(p.offset(1), g); |
| 70 | + ptr::write_volatile(p.offset(2), r); |
| 71 | + } |
65 | 72 | };
|
66 | 73 | let write_pixel: PixelWriter = match mi.pixel_format() {
|
67 | 74 | PixelFormat::RGB => &write_pixel_rgb,
|
|
0 commit comments