From 7878104e2898ef98779f5d7a6617737e84f708bb Mon Sep 17 00:00:00 2001 From: Henrik Karlsson Date: Tue, 10 Oct 2023 20:12:04 +0200 Subject: [PATCH] Fixes bug in revoke and in uart --- common/inc/s3k/pmp.h | 7 ------- common/inc/s3k/s3k.h | 1 - common/inc/s3k/util.h | 4 ++++ common/src/drivers/ns16550a.c | 10 ++++++++-- kernel/src/cap_ops.c | 2 +- 5 files changed, 13 insertions(+), 11 deletions(-) delete mode 100644 common/inc/s3k/pmp.h diff --git a/common/inc/s3k/pmp.h b/common/inc/s3k/pmp.h deleted file mode 100644 index 4656b81b..00000000 --- a/common/inc/s3k/pmp.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#include "s3k/types.h" - -void s3k_napot_decode(s3k_napot_t napot_addr, s3k_addr_t *begin, - s3k_addr_t *end); -s3k_napot_t s3k_napot_encode(s3k_addr_t base, s3k_addr_t size); diff --git a/common/inc/s3k/s3k.h b/common/inc/s3k/s3k.h index f1e34acc..44c3e9ea 100644 --- a/common/inc/s3k/s3k.h +++ b/common/inc/s3k/s3k.h @@ -1,7 +1,6 @@ #ifndef S3K_H #define S3K_H -#include "s3k/pmp.h" #include "s3k/syscall.h" #include "s3k/types.h" #include "s3k/util.h" diff --git a/common/inc/s3k/util.h b/common/inc/s3k/util.h index e4a19319..a39a3ce2 100644 --- a/common/inc/s3k/util.h +++ b/common/inc/s3k/util.h @@ -14,6 +14,10 @@ bool s3k_is_valid(s3k_cap_t a); bool s3k_is_parent(s3k_cap_t a, s3k_cap_t b); bool s3k_is_derivable(s3k_cap_t a, s3k_cap_t b); +void s3k_napot_decode(s3k_napot_t napot_addr, s3k_addr_t *begin, + s3k_addr_t *end); +s3k_napot_t s3k_napot_encode(s3k_addr_t base, s3k_addr_t size); + static inline bool s3k_is_ready(s3k_state_t state) { return state == 0; diff --git a/common/src/drivers/ns16550a.c b/common/src/drivers/ns16550a.c index d57319fb..1ef2dfb5 100644 --- a/common/src/drivers/ns16550a.c +++ b/common/src/drivers/ns16550a.c @@ -1,10 +1,16 @@ #include "drivers/uart.h" +#define LINE_STATUS_DATA_READY 0x1 +#define FIFO_CONTROL_REGISTER 0x2 +#define LINE_CONTROL_REGISTER 0x3 +#define LINE_STATUS_REGISTER 0x5 + extern volatile char _uart[]; void uart_init(void) { - /** TODO: Proper init code for uart */ + _uart[LINE_CONTROL_REGISTER] = 0x3; + _uart[FIFO_CONTROL_REGISTER] = 0x1; } int uart_putc(char c) @@ -15,7 +21,7 @@ int uart_putc(char c) int uart_getc(void) { - while (!(_uart[5] & 0x1)) + while (!(_uart[LINE_STATUS_REGISTER] & LINE_STATUS_DATA_READY)) ; return _uart[0]; } diff --git a/kernel/src/cap_ops.c b/kernel/src/cap_ops.c index 2ca9ea81..9803a28e 100644 --- a/kernel/src/cap_ops.c +++ b/kernel/src/cap_ops.c @@ -85,7 +85,7 @@ err_t cap_delete(cte_t c) void cap_reclaim(cte_t p, cap_t pcap, cte_t c, cap_t ccap) { - if ((cte_prev(c) != p) || cte_cap(c).raw == ccap.raw) + if ((cte_prev(c) != p) || cte_cap(c).raw != ccap.raw) return; cte_delete(c);