From d21654dd4bdbdcfe6ac7dfed63b457110ea54510 Mon Sep 17 00:00:00 2001
From: able <abl3theabove@gmail.com>
Date: Sat, 4 May 2024 13:20:30 -0500
Subject: [PATCH] Starting to spec out the interface with the kernel

---
 sysdata/spec/Memory service spec.md | 58 +++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)
 create mode 100644 sysdata/spec/Memory service spec.md

diff --git a/sysdata/spec/Memory service spec.md b/sysdata/spec/Memory service spec.md
new file mode 100644
index 0000000..0d74e3c
--- /dev/null
+++ b/sysdata/spec/Memory service spec.md	
@@ -0,0 +1,58 @@
+# Memory service spec
+The memory service uses the first byte in the message to identify the request type.
+
+## Allocate (12 bytes)
+[0]     -> 0
+[1]     -> Page count
+<!-- Currently this does not allocate here, check r1 for a ptr to alloc to -->
+[2..10] -> ptr to alloc at
+
+## Deallocate (12 bytes)
+<!-- Currently this does not deallocate -->
+[0]     -> 1
+[1]     -> Page count
+[2..10] -> ptr to dealloc from
+
+## Map Device Into Memory
+Typically only used for simple drivers such as vga.
+<!-- Unimp -->
+[0]      -> 2
+[1]      -> Page count
+[2..10]  -> HostID
+[11..19] -> DeviceID
+
+## Unmap Device From Memory
+<!-- Unimp -->
+[0]      -> 3
+[1]      -> Page count
+[2..10]  -> HostID
+[11..19] -> DeviceID
+
+## Set Memory Quota
+<!-- unimp -->
+[0]      -> 4
+[1..9]   -> HostID
+[10..18] -> ProcessID
+[19]     -> Refer to the Memory Quota Table
+[20..28] -> Memory quota. In pages of memory. Multiply by 4096 to get the total byte count.
+
+### Memory Quota Table
+0 -> No quota.
+1 -> Soft quota. Notifies the process supervisor.
+2 -> Hard quota. Refuses to allocate above the quota.
+3 -> Kill quota. Kill the process and notify the supervisor when the process tries to allocate above the quota.
+
+## Set Buffer Quota
+<!-- unimp -->
+[0]      -> 4
+[1..9]   -> HostID
+[10..18] -> BufferID
+[19]     -> Refer to the Buffer Quota Table
+[20..28] -> Buffer quota. In pages of memory. Multiply by 4096 to get the total byte count.
+
+### Buffer Quota Table
+<!-- Because of the abusability of buffers there is no Kill Quota -->
+0 -> No quota
+1 -> Soft quota. Notify supervisor of quota violation Buffer Message
+2 -> Hard quota. Return an error message to the process that sent the message.
+ 
\ No newline at end of file