From 615e3302c9dd358bb64cd56d1f3814ad8d5df84d Mon Sep 17 00:00:00 2001 From: vetch Date: Sat, 4 Jan 2020 19:37:32 +0100 Subject: rearranged files, updated makefile --- src/PL0/PL0_test.c | 34 ++++++++++++++++++++++++++++++++++ src/PL0/PL0_test.ld | 19 +++++++++++++++++++ src/PL0/PL0_utils.c | 19 +++++++++++++++++++ src/PL0/PL0_utils.h | 6 ++++++ 4 files changed, 78 insertions(+) create mode 100644 src/PL0/PL0_test.c create mode 100644 src/PL0/PL0_test.ld create mode 100644 src/PL0/PL0_utils.c create mode 100644 src/PL0/PL0_utils.h (limited to 'src/PL0') diff --git a/src/PL0/PL0_test.c b/src/PL0/PL0_test.c new file mode 100644 index 0000000..0bfebc7 --- /dev/null +++ b/src/PL0/PL0_test.c @@ -0,0 +1,34 @@ +#include "PL0_utils.h" + +// entry point - must remain the only function in the file! +void PL0_main(void) +{ + // If loading program to userspace and handling of svc are + // implemented correctly, this shall get printed + puts("Hello userspace! Type 'f' if you want me to try accessing " + "kernel memory!"); + + while (1) + { + char c = getchar(); + + if (c == '\r') + putchar('\n'); + + putchar(c); + + if (c == 'f') + { + // if we're indeed in PL0, we should trigger the abort + // handler now, when trying to access memory we're not + // allowed to + puts("Attempting to read kernel memory from userspace :d"); + char first_kernel_byte[2]; + + first_kernel_byte[0] = *(char*) 0x0; + first_kernel_byte[1] = '\0'; + + puts(first_kernel_byte); + } + } +} diff --git a/src/PL0/PL0_test.ld b/src/PL0/PL0_test.ld new file mode 100644 index 0000000..b1d06f4 --- /dev/null +++ b/src/PL0/PL0_test.ld @@ -0,0 +1,19 @@ +/* linker script for creating the example userspace program PL0_test + */ + +/* no ENTRY() statement - this executable is run by jumping to it */ + +SECTIONS +{ + /* my thought up address userspace programs should run from */ + . = 0xaaa00000; + + __start = .; + .another_weird_section_name_that_doesnt_matter : + { + /* have entry point at the beginning */ + KEEP(PL0_test.o) + *(*) + } + __end = .; +} diff --git a/src/PL0/PL0_utils.c b/src/PL0/PL0_utils.c new file mode 100644 index 0000000..d83edb9 --- /dev/null +++ b/src/PL0/PL0_utils.c @@ -0,0 +1,19 @@ +#include +#include + +#include "svc_interface.h" +#include "PL0_utils.h" + +// most generic definition possible +// the actual function defined in svc.S +uint32_t svc(enum svc_type, ...); + +void putchar(char character) +{ + svc(UART_PUTCHAR, character); +} + +char getchar(void) +{ + return svc(UART_GETCHAR); +} diff --git a/src/PL0/PL0_utils.h b/src/PL0/PL0_utils.h new file mode 100644 index 0000000..c26a100 --- /dev/null +++ b/src/PL0/PL0_utils.h @@ -0,0 +1,6 @@ +#ifndef PL0_UTILS_H +#define PL0_UTILS_H + +#include "io.h" + +#endif // PL0_UTILS_H -- cgit v1.2.3 10-19doc: Produce stylable HTML for @deftp, @deffn, etc....Ludovic Courtès 2020-10-17doc: Generate cross-references in code snippets to the Guile manual....Ludovic Courtès 2020-10-17doc: Allow code snippets in the cookbook to link to the manual....Ludovic Courtès 2020-10-17doc: Move manual index creation to a separate derivation....Ludovic Courtès 2020-10-17doc: Remove 'build.scm' from the source of the manual....Ludovic Courtès 2020-09-04doc: Syntax highlighting now handles @var within @lisp....Ludovic Courtès 2020-05-25doc: Remove one use of 'file-append*'....Ludovic Courtès 2020-05-18doc: Inherit md5.scm fix in custom 'guile-lib' variant....Ludovic Courtès 2020-05-02doc: Fix building the cookbook....Björn Höfling 2020-04-21doc: Include *.json files in the source....Ludovic Courtès 2020-04-13doc: Improve anchor collection....Ludovic Courtès 2020-04-13doc: Avoid invalid 'match' pattern in 'syntax-highlighted-html'....Ludovic Courtès 2020-04-13doc: Emit hyperlinks in HTML output for @lisp snippets....Ludovic Courtès 2020-01-12doc: Make sure 'htmlxref.cnf' is honored....Ludovic Courtès 2019-11-28doc: Handle right arrows in 'syntax-highlighted-html'....Ludovic Courtès 2019-10-22doc: Use the right title in HTML indices for the cookbook....Ludovic Courtès 2019-10-21doc: More responsive online manual....Julien Lepiller 2019-10-21doc: Add support for "guix-cookbook.texi" to 'build.scm'....Ludovic Courtès 2019-09-25doc: Support paren matching via CSS hover....Ludovic Courtès 2019-09-07doc: Work around (htmlprag) parser issue....Ludovic Courtès 2019-09-07doc: Highlight Scheme syntax in the HTML output....Ludovic Courtès 2019-07-16doc: Add 'images' directory next to HTML pages....Ludovic Courtès 2019-07-15doc: Build a top-level index of the manuals....Ludovic Courtès 2019-07-15doc: Generalize build procedures of HTML indexes....Ludovic Courtès 2019-07-07build: Add 'doc/build.scm' to build on-line copies of the manual....Ludovic Courtès