Fix diff script

Closes #32
pull/35/head
Andre Richter 5 years ago
parent dea5017128
commit 9547bf77af
No known key found for this signature in database
GPG Key ID: 2116C1AB102F615E

@ -133,4 +133,5 @@ diff -uNr 01_wait_forever/src/runtime_init.rs 02_runtime_init/src/runtime_init.r
+
+ crate::kernel_init()
+}
```

@ -217,8 +217,7 @@ diff -uNr 02_runtime_init/src/print.rs 03_hacky_hello_world/src/print.rs
+/// Carbon copy from https://doc.rust-lang.org/src/std/macros.rs.html
+#[macro_export]
+macro_rules! println {
+ () => ($crate::print!("
"));
+ () => ($crate::print!("\n"));
+ ($($arg:tt)*) => ({
+ $crate::print::_print(format_args_nl!($($arg)*));
+ })
@ -229,4 +228,5 @@ diff -uNr 02_runtime_init/src/print.rs 03_hacky_hello_world/src/print.rs
+
+ bsp::console().write_fmt(args).unwrap();
+}
```

@ -150,4 +150,5 @@ diff -uNr 03_hacky_hello_world/src/runtime_init.rs 04_zero_overhead_abstraction/
extern "C" {
// Boundaries of the .bss section, provided by the linker script.
static mut __bss_start: u64;
```

@ -167,9 +167,8 @@ diff -uNr 04_zero_overhead_abstraction/src/bsp/rpi.rs 05_safe_globals/src/bsp/rp
- unsafe {
- core::ptr::write_volatile(0x3F20_1000 as *mut u8, c as u8);
+ // Convert newline to carrige return + newline.
+ if c == '
' {
+ self.write_char(' ')
+ if c == '\n' {
+ self.write_char('\r')
}
+
+ self.write_char(c);
@ -346,4 +345,5 @@ diff -uNr 04_zero_overhead_abstraction/src/main.rs 05_safe_globals/src/main.rs
+ println!("[2] Stopping here.");
arch::wait_forever()
}
```

@ -65,8 +65,8 @@ doc:
xdg-open target/$(TARGET)/doc/kernel/index.html
ifeq ($(QEMU_MACHINE_TYPE),)
$(info This board is not yet supported for QEMU.)
qemu:
@echo "This board is not yet supported for QEMU."
else
qemu: all
$(DOCKER_CMD) $(DOCKER_ARG_CURDIR) $(CONTAINER_UTILS) \

@ -118,8 +118,8 @@ diff -uNr 05_safe_globals/Makefile 06_drivers_gpio_uart/Makefile
xdg-open target/$(TARGET)/doc/kernel/index.html
+ifeq ($(QEMU_MACHINE_TYPE),)
+$(info This board is not yet supported for QEMU.)
+qemu:
+ @echo "This board is not yet supported for QEMU."
+else
qemu: all
$(DOCKER_CMD) $(DOCKER_ARG_CURDIR) $(CONTAINER_UTILS) \
@ -522,9 +522,8 @@ diff -uNr 05_safe_globals/src/bsp/driver/bcm/bcm2xxx_pl011_uart.rs 06_drivers_gp
+ fn write_str(&mut self, s: &str) -> fmt::Result {
+ for c in s.chars() {
+ // Convert newline to carrige return + newline.
+ if c == '
' {
+ self.write_char(' ')
+ if c == '\n' {
+ self.write_char('\r')
+ }
+
+ self.write_char(c);
@ -624,9 +623,8 @@ diff -uNr 05_safe_globals/src/bsp/driver/bcm/bcm2xxx_pl011_uart.rs 06_drivers_gp
+ let mut ret = inner.DR.get() as u8 as char;
+
+ // Convert carrige return to newline.
+ if ret == ' ' {
+ ret = '
'
+ if ret == '\r' {
+ ret = '\n'
+ }
+
+ ret
@ -746,9 +744,8 @@ diff -uNr 05_safe_globals/src/bsp/rpi.rs 06_drivers_gpio_uart/src/bsp/rpi.rs
- fn write_str(&mut self, s: &str) -> fmt::Result {
- for c in s.chars() {
- // Convert newline to carrige return + newline.
- if c == '
' {
- self.write_char(' ')
- if c == '\n' {
- self.write_char('\r')
- }
-
- self.write_char(c);
@ -934,8 +931,7 @@ diff -uNr 05_safe_globals/src/main.rs 06_drivers_gpio_uart/src/main.rs
+
+ // UART should be functional now. Wait for user to hit Enter.
+ loop {
+ if bsp::console().read_char() == '
' {
+ if bsp::console().read_char() == '\n' {
+ break;
+ }
+ }
@ -959,4 +955,5 @@ diff -uNr 05_safe_globals/src/main.rs 06_drivers_gpio_uart/src/main.rs
+ bsp::console().write_char(c);
+ }
}
```

@ -72,9 +72,11 @@ doc:
xdg-open target/$(TARGET)/doc/kernel/index.html
ifeq ($(QEMU_MACHINE_TYPE),)
$(info This board is not yet supported for QEMU.)
qemu:
@echo "This board is not yet supported for QEMU."
qemuasm:
@echo "This board is not yet supported for QEMU."
else
qemu: all
$(DOCKER_CMD) $(DOCKER_ARG_CURDIR) $(CONTAINER_UTILS) \

@ -120,11 +120,13 @@ diff -uNr 06_drivers_gpio_uart/Makefile 07_uart_chainloader/Makefile
all: clean $(OUTPUT)
@@ -67,12 +74,22 @@
@@ -67,12 +74,24 @@
ifeq ($(QEMU_MACHINE_TYPE),)
$(info This board is not yet supported for QEMU.)
qemu:
@echo "This board is not yet supported for QEMU."
+
+qemuasm:
+ @echo "This board is not yet supported for QEMU."
else
qemu: all
$(DOCKER_CMD) $(DOCKER_ARG_CURDIR) $(CONTAINER_UTILS) \
@ -189,9 +191,8 @@ diff -uNr 06_drivers_gpio_uart/src/bsp/driver/bcm/bcm2xxx_pl011_uart.rs 07_uart_
+ }
- // Convert carrige return to newline.
- if ret == ' ' {
- ret = '
'
- if ret == '\r' {
- ret = '\n'
+ fn clear(&self) {
+ let mut r = &self.inner;
+ r.lock(|inner| loop {
@ -300,14 +301,13 @@ diff -uNr 06_drivers_gpio_uart/src/main.rs 07_uart_chainloader/src/main.rs
- // UART should be functional now. Wait for user to hit Enter.
- loop {
- if bsp::console().read_char() == '
' {
- if bsp::console().read_char() == '\n' {
- break;
- }
+ println!(" __ __ _ _ _ _ ");
+ println!("| \/ (_)_ _ (_) | ___ __ _ __| |");
+ println!("| |\/| | | ' \| | |__/ _ \/ _` / _` |");
+ println!("|_| |_|_|_||_|_|____\___/\__,_\__,_|");
+ println!("| \\/ (_)_ _ (_) | ___ __ _ __| |");
+ println!("| |\\/| | | ' \\| | |__/ _ \\/ _` / _` |");
+ println!("|_| |_|_|_||_|_|____\\___/\\__,_\\__,_|");
+ println!();
+ println!("{:^37}", bsp::board_name());
+ println!();
@ -347,8 +347,7 @@ diff -uNr 06_drivers_gpio_uart/src/main.rs 07_uart_chainloader/src/main.rs
- println!("[2] Chars written: {}", bsp::console().chars_written());
- println!("[3] Echoing input now");
+ println!("[ML] Loaded! Executing the payload now
");
+ println!("[ML] Loaded! Executing the payload now\n");
+ bsp::console().flush();
- loop {
@ -469,4 +468,5 @@ diff -uNr 06_drivers_gpio_uart/src/runtime_init.rs 07_uart_chainloader/src/runti
+pub fn get() -> &'static dyn RunTimeInit {
+ &Traitor {}
}
```

@ -70,8 +70,8 @@ doc:
xdg-open target/$(TARGET)/doc/kernel/index.html
ifeq ($(QEMU_MACHINE_TYPE),)
$(info This board is not yet supported for QEMU.)
qemu:
@echo "This board is not yet supported for QEMU."
else
qemu: all
$(DOCKER_CMD) $(DOCKER_ARG_CURDIR) $(CONTAINER_UTILS) \

@ -70,11 +70,13 @@ diff -uNr 07_uart_chainloader/Makefile 08_timestamps/Makefile
all: clean $(OUTPUT)
@@ -74,21 +72,16 @@
@@ -74,23 +72,16 @@
ifeq ($(QEMU_MACHINE_TYPE),)
$(info This board is not yet supported for QEMU.)
qemu:
@echo "This board is not yet supported for QEMU."
-
-qemuasm:
- @echo "This board is not yet supported for QEMU."
else
qemu: all
$(DOCKER_CMD) $(DOCKER_ARG_CURDIR) $(CONTAINER_UTILS) \
@ -237,9 +239,8 @@ diff -uNr 07_uart_chainloader/src/bsp/driver/bcm/bcm2xxx_pl011_uart.rs 08_timest
+ let mut ret = inner.DR.get() as u8 as char;
+
+ // Convert carrige return to newline.
+ if ret == ' ' {
+ ret = '
'
+ if ret == '\r' {
+ ret = '\n'
+ }
+
+ ret
@ -343,9 +344,9 @@ diff -uNr 07_uart_chainloader/src/main.rs 08_timestamps/src/main.rs
- use interface::console::All;
-
- println!(" __ __ _ _ _ _ ");
- println!("| \/ (_)_ _ (_) | ___ __ _ __| |");
- println!("| |\/| | | ' \| | |__/ _ \/ _` / _` |");
- println!("|_| |_|_|_||_|_|____\___/\__,_\__,_|");
- println!("| \\/ (_)_ _ (_) | ___ __ _ __| |");
- println!("| |\\/| | | ' \\| | |__/ _ \\/ _` / _` |");
- println!("|_| |_|_|_||_|_|____\\___/\\__,_\\__,_|");
- println!();
- println!("{:^37}", bsp::board_name());
- println!();
@ -389,8 +390,7 @@ diff -uNr 07_uart_chainloader/src/main.rs 08_timestamps/src/main.rs
+ println!(" {}. {}", i + 1, driver.compatible());
}
- println!("[ML] Loaded! Executing the payload now
");
- println!("[ML] Loaded! Executing the payload now\n");
- bsp::console().flush();
-
- // Use black magic to get a function pointer.
@ -417,8 +417,7 @@ diff -uNr 07_uart_chainloader/src/print.rs 08_timestamps/src/print.rs
-/// Carbon copy from https://doc.rust-lang.org/src/std/macros.rs.html
#[macro_export]
macro_rules! println {
() => ($crate::print!("
"));
() => ($crate::print!("\n"));
- ($($arg:tt)*) => ({
- $crate::print::_print(format_args_nl!($($arg)*));
+ ($string:expr) => ({
@ -594,4 +593,5 @@ diff -uNr 07_uart_chainloader/src/runtime_init.rs 08_timestamps/src/runtime_init
- &Traitor {}
+ crate::kernel_init()
}
```

@ -14,7 +14,8 @@ DIFF=$(
$1 $2 \
| sed -r "s/[12][90][127][90]-.*//g" \
| sed -r "s/[[:space:]]*$//g" \
| sed -r "s/%/modulo/g"
| sed -r "s/%/modulo/g" \
| sed -r "s/diff -uNr -x README.md -x kernel -x kernel8.img -x Cargo.lock -x target/\ndiff -uNr/g"
)
HEADER="## Diff to previous"
@ -23,8 +24,8 @@ ORIGINAL=$(
| sed -rn "/$HEADER/q;p"
)
printf "$ORIGINAL" > "$2/README.md"
printf "\n\n$HEADER\n" >> "$2/README.md"
echo "$ORIGINAL" > "$2/README.md"
printf "\n$HEADER\n" >> "$2/README.md"
printf "\`\`\`diff\n" >> "$2/README.md"
printf "${DIFF//'diff -uNr -x README.md -x kernel -x kernel8.img -x Cargo.lock -x target'/'\ndiff -uNr'}" >> "$2/README.md"
echo "$DIFF" >> "$2/README.md"
printf "\n\`\`\`\n" >> "$2/README.md"

Loading…
Cancel
Save