Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Some test suite tweaks #24

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

Merged
GabrielMajeri merged 5 commits into rust-osdev:master from HadrienG2:test-cleanup
Sep 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions uefi-test-runner/src/boot/memory.rs
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ fn memory_map(bt: &BootServices) {
let first_desc = desc_iter.next().unwrap();

let phys_start = first_desc.phys_start;
let page_count = first_desc.page_count;

assert_eq!(phys_start, 0, "Memory does not start at address 0");
assert!(page_count != 0, "Memory map entry has zero size");
Copy link
Contributor Author

@HadrienG2 HadrienG2 Sep 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just another sanity check. The UEFI spec mandates this, and it can be used to check that we did not get a memory block full of zeroes...

GabrielMajeri reacted with thumbs up emoji
}
41 changes: 25 additions & 16 deletions uefi-test-runner/src/proto/console/gop.rs
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use uefi::table::boot::BootServices;
use uefi::proto::console::gop::{GraphicsOutput, BltOp, BltPixel};
use uefi::proto::console::gop::{GraphicsOutput, BltOp, BltPixel, PixelFormat};
use uefi_exts::BootServicesExt;

pub fn test(bt: &BootServices) {
Expand Down Expand Up @@ -48,29 +48,38 @@ fn fill_color(gop: &mut GraphicsOutput) {
fn draw_fb(gop: &mut GraphicsOutput) {
let mi = gop.current_mode_info();
let stride = mi.stride();
// BUG: we should check we have enough space to draw.
// let (width, height) = mi.resolution();
Copy link
Contributor Author

@HadrienG2 HadrienG2 Sep 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

GabrielMajeri reacted with thumbs up emoji
let (width, height) = mi.resolution();

let fb = unsafe { gop.frame_buffer() };

let mut set_pixel = |(row, column), (r, g, b)| {
let index = (row * stride) + column;

// BUG: we assume the pixel format is 32-bit BGR, as it often is on x86.
// For RGB the red / blue channels will be inverted.
Copy link
Contributor Author

@HadrienG2 HadrienG2 Sep 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Simplified the functionality of set_pixel along the way to reduce code duplication between RGB and BGR.

let bi = 4 * index;
let gi = 4 * index + 1;
let ri = 4 * index + 2;

fb[bi] = b;
fb[gi] = g;
fb[ri] = r;
type PixelWriter<'a> = &'a Fn(&mut [u8], (u8, u8, u8));
let write_pixel_rgb = |pixel: &mut [u8], (r, g, b)| {
pixel[0] = r;
pixel[1] = g;
pixel[2] = b;
};
let write_pixel_bgr = |pixel: &mut [u8], (r, g, b)| {
pixel[0] = b;
pixel[1] = g;
pixel[2] = r;
};
let write_pixel: PixelWriter = match mi.pixel_format() {
PixelFormat::RGB => &write_pixel_rgb,
PixelFormat::BGR => &write_pixel_bgr,
_ => {
info!("This pixel format is not supported by the drawing demo");
return;
}
};

let mut fill_rectangle = |(x1, y1), (x2, y2), color| {
assert!((x1 < width) && (x2 < width), "Bad X coordinate");
assert!((y1 < height) && (y2 < height), "Bad Y coordinate");
for row in y1..y2 {
for column in x1..x2 {
set_pixel((row, column), color);
let index = (row * stride) + column;
let pixel = &mut fb[4*index..4*index+3];
write_pixel(pixel, color);
}
}
};
Expand Down
12 changes: 9 additions & 3 deletions uefi-test-runner/src/proto/console/stdout.rs
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use uefi::prelude::*;
use uefi::proto::console::text::{Output, Color};

pub fn test(stdout: &mut Output) {
Expand Down Expand Up @@ -33,9 +34,14 @@ fn change_color(stdout: &mut Output) {
fn center_text(stdout: &mut Output) {
// Move the cursor.
// This will make this `info!` line below be (somewhat) centered.
stdout.enable_cursor(true).expect("Failed to enable cursor");
stdout.enable_cursor(true).unwrap_or_else(|s| match s {
Status::Unsupported => info!("Cursor visibility control unavailable"),
_ => panic!("Failed to show cursor")
});
stdout.set_cursor_position(24, 0).expect("Failed to move cursor");
stdout.enable_cursor(false).expect("Failed to disable cursor");

info!("# uefi-rs test runner");
stdout.enable_cursor(false).unwrap_or_else(|s| match s {
Status::Unsupported => info!("Cursor visibility control unavailable"),
_ => panic!("Failed to hide cursor")
});
Copy link
Contributor Author

@HadrienG2 HadrienG2 Sep 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to fixing the bug in #1, this also ensures that the new debug messages pointing out that showing and hiding the cursor is not supported will not corrupt the display.

GabrielMajeri reacted with thumbs up emoji
}

AltStyle によって変換されたページ (->オリジナル) /