Skip to content
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

Support SBRK #125

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions entities/osv.rwx.entities.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-
name: dover.Kernel.Code.ApplyTag.sbrk_zero
elf_name: sbrk_zero
kind: symbol
tag_all: true
optional: true
2 changes: 2 additions & 0 deletions osv/heap.dpl
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ require:
init SOC.Memory.BRAM_CTRL_0 {}
init SOC.Memory.DMA_0 {}
init SOC.Memory.QSPI_1 {}

init SOC.MAILBOX {}

init dover.Kernel.Code.ApplyTag.ucHeap {RawHeap}
init dover.Kernel.Code.ApplyTag.dover_ptr_zero {ModColor}
Expand Down
2 changes: 2 additions & 0 deletions osv/none.dpl
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ require:
init SOC.IO.GPIO_1 {}
init SOC.IO.Ethernet_0 {}

init SOC.MAILBOX {}

init SOC.Memory.BRAM_CTRL_0 {}
init SOC.Memory.DMA_0 {}
init SOC.Memory.QSPI_1 {}
Expand Down
15 changes: 13 additions & 2 deletions osv/rwx.dpl
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,21 @@ import:
metadata:
Rd,
Wr,
Ex
Ex,
sbrk


policy:
rwxPol =
loadGrp(mem == [-Rd] -> fail "read violation")
// Initialize or delete tags for memory when sbrk allocates or deallocates it
storeGrp(code == [+Ex], val == [+sbrk], env == _, mem == [-Rd, -Wr] -> mem = mem[+Rd, +Wr], env = env)
^ loadGrp(code == [+Ex], env == _, mem == [+Rd, +sbrk] -> res = {sbrk}, env = env)
^ storeGrp(code == [+Ex], val == [+sbrk], env == _, mem == [+Rd, +Wr] -> mem = {})

^ loadGrp(mem == [-Rd] -> fail "read violation")
^ storeGrp(mem == [-Wr] -> fail "write violation")
^ allGrp(code == [-Ex] -> fail "execute violation")

^ loadGrp (code == [+Ex], env == _, mem == [+Rd] -> res = {}, env = env)
^ storeGrp (code == [+Ex], env == _, mem == [+Wr] -> mem = mem, env = env)
^ allGrp(code == [+Ex], env == _ -> env = env)
Expand Down Expand Up @@ -83,6 +90,8 @@ require:
init SOC.IO.GPIO_1 {Rd, Wr}
init SOC.IO.Ethernet_0 {Rd, Wr}

init SOC.IO.MAILBOX {Rd, Wr}

init SOC.Memory.BRAM_CTRL_0 {Rd, Wr}
init SOC.Memory.DMA_0 {Rd, Wr}
init SOC.Memory.QSPI_1 {Rd}
Expand All @@ -91,4 +100,6 @@ require:
init elf.Section.SHF_EXECINSTR {Ex}
init elf.Section.SHF_WRITE {Rd, Wr}

init dover.Kernel.Code.ApplyTag.sbrk_zero {Rd, sbrk}


34 changes: 34 additions & 0 deletions policy_tests/tests/mailbox.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <stdint.h>
#include <stdio.h>

#include "test_status.h"
#include "test.h"

int test_main(void)
{
test_positive();

uint32_t* const PEX_MB = (uint32_t*)0x70000080U;
uint32_t* const AP_MB = (uint32_t*)0x70000090U;
uint32_t* const MB_IRQ = (uint32_t*)0x700000a0U;
printf("Initial PEX mailbox value: %x\n", *PEX_MB);
uint32_t pex = *PEX_MB;
*AP_MB = 0x10101010;
*MB_IRQ = 1;
while (1) {
if (pex != *PEX_MB) {
pex = *PEX_MB;
if (pex < 0xFFFFFFFFU) {
printf("Recieved %x from PEX. Sending %x\n", pex, pex + 0x10101010);
*AP_MB = pex + 0x10101010;
*MB_IRQ = 1;
} else {
printf("Received %x from PEX.\n", pex);
break;
}
}
}

test_pass();
return test_done();
}
15 changes: 15 additions & 0 deletions policy_tests/tests/sbrk.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include <unistd.h>

#include "test_status.h"
#include "test.h"

int test_main(void)
{
test_positive();

volatile uint64_t* brk = sbrk(sizeof(uint64_t));
*brk = 0;

test_pass();
return test_done();
}