summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Source/Kernel/TaskManager/Process-sc.class.cpp18
-rw-r--r--Source/Kernel/TaskManager/Process.class.h4
-rw-r--r--Source/Library/Common/Heap.class.cpp27
-rw-r--r--Source/Library/Interface/FSNode.iface.h37
-rw-r--r--Source/Library/Interface/File.iface.h18
-rw-r--r--Source/Library/Interface/Process.iface.h34
-rw-r--r--Source/Library/Interface/ReadME.txt19
-rw-r--r--Source/Library/Interface/Sys.iface.h10
-rw-r--r--Source/Library/Interface/Thread.iface.h6
-rw-r--r--Source/Library/Interface/VirtualTerminal.iface.h31
-rw-r--r--Source/Library/Userland/Binding/Process.class.h8
11 files changed, 120 insertions, 92 deletions
diff --git a/Source/Kernel/TaskManager/Process-sc.class.cpp b/Source/Kernel/TaskManager/Process-sc.class.cpp
index 5a94c81..8564c22 100644
--- a/Source/Kernel/TaskManager/Process-sc.class.cpp
+++ b/Source/Kernel/TaskManager/Process-sc.class.cpp
@@ -9,8 +9,8 @@
call_t Process::m_callTable[] = {
CALL0(PRIF_EXIT, &Process::exitSC),
- CALL1(PRIF_ALLOCPAGE, &Process::allocPageSC),
- CALL1(PRIF_FREEPAGE, &Process::freePageSC),
+ CALL1(PRIF_ALLOCPAGES, &Process::allocPagesSC),
+ CALL1(PRIF_FREEPAGES, &Process::freePagesSC),
CALL0(PRIF_GETPID, &Process::getPid),
CALL0(PRIF_GETPPID, &Process::getPpid),
CALL0(PRIF_ARGC, &Process::argcSC),
@@ -50,11 +50,12 @@ u32int Process::exitSC() {
return 0;
}
-u32int Process::allocPageSC(u32int pos) {
+u32int Process::allocPagesSC(u32int pos, u32int count) {
if (Task::currProcess() != this) return 1;
if ((pos & 0x00000FFF) != 0) pos = (pos & 0xFFFFF000) + 0x1000;
- if (pos >= 0xC0000000) return 1;
- m_pagedir->allocFrame(pos, true, true);
+ if (pos + (count - 1) * 0x1000 >= 0xC0000000) return 1;
+ for (u32int i = 0; i < count; i++)
+ m_pagedir->allocFrame(pos + (i * 0x1000), true, true);
return 0;
}
@@ -73,11 +74,12 @@ u32int Process::argvSC(u32int idx) {
return (u32int) - 1;
}
-u32int Process::freePageSC(u32int pos) {
+u32int Process::freePagesSC(u32int pos, u32int count) {
if (Task::currProcess() != this) return 1;
if ((pos & 0x00000FFF) != 0) pos = (pos & 0xFFFFF000) + 0x1000;
- if (pos >= 0xC0000000) return 1;
- m_pagedir->freeFrame(pos);
+ if (pos + (count - 1) * 0x1000 >= 0xC0000000) return 1;
+ for (u32int i = 0; i < count; i++)
+ m_pagedir->freeFrame(pos + (i * 0x1000));
return 0;
}
diff --git a/Source/Kernel/TaskManager/Process.class.h b/Source/Kernel/TaskManager/Process.class.h
index 053a640..852c6cc 100644
--- a/Source/Kernel/TaskManager/Process.class.h
+++ b/Source/Kernel/TaskManager/Process.class.h
@@ -57,8 +57,8 @@ class Process : public Ressource {
u32int exitSC();
u32int argcSC();
u32int argvSC(u32int);
- u32int allocPageSC(u32int);
- u32int freePageSC(u32int);
+ u32int allocPagesSC(u32int, u32int);
+ u32int freePagesSC(u32int, u32int);
u32int startSC(); //Permits parent process to start run of process
u32int autoDeleteSC(u32int); //If true, process will auto-delete when it finishes. Else, it must be deleted by parent, while waiting for it.
u32int pushArgSC(u32int);
diff --git a/Source/Library/Common/Heap.class.cpp b/Source/Library/Common/Heap.class.cpp
index 45a3669..2491e00 100644
--- a/Source/Library/Common/Heap.class.cpp
+++ b/Source/Library/Common/Heap.class.cpp
@@ -2,11 +2,6 @@
#ifdef THIS_IS_MELON_KERNEL
#include <MemoryManager/PageDirectory.class.h>
-#define ALLOC(x) m_pagedir->allocFrame(x, m_user, m_rw)
-#define FREE(x) m_pagedir->freeFrame(x)
-#else
-#define ALLOC(x) m_process.allocPage(x)
-#define FREE(x) m_process.freePage(x)
#endif
#ifdef THIS_IS_MELON_KERNEL
@@ -42,11 +37,13 @@ void Heap::create(u32int start, u32int size, u32int idxsize) {
#endif
//Allocate frames for heap
- for (u32int i = start ; i < m_end; i += 0x1000) {
- ALLOC(i);
- }
#ifdef THIS_IS_MELON_KERNEL
+ for (u32int i = m_start ; i < m_end; i += 0x1000) {
+ m_pagedir->allocFrame(i, m_user, m_rw);
+ }
m_pagedir->switchTo();
+#else
+ m_process.allocPages(start, (m_end - start) / 0x1000);
#endif
m_index.data = (heap_header_t **)start; //Set index start. start == start of all heap
@@ -75,9 +72,13 @@ void Heap::expand(u32int quantity) {
u32int newEnd = m_end + quantity;
- for (u32int i = m_end; i < newEnd; i++) {
- ALLOC(i);
+#ifdef THIS_IS_MELON_KERNEL
+ for (u32int i = m_start ; i < m_end; i += 0x1000) {
+ m_pagedir->allocFrame(i, m_user, m_rw);
}
+#else
+ m_process.allocPages(m_start, (m_end - m_start) / 0x1000);
+#endif
heap_footer_t *last_footer = (heap_footer_t*) (m_end - sizeof(heap_footer_t));
heap_header_t *last_header = last_footer->header;
@@ -130,9 +131,13 @@ void Heap::contract() { //Automatically work out how much we can contract
last_footer->header = last_header;
insertIntoIndex(last_header);
+#ifdef THIS_IS_MELON_KERNEL
for (u32int i = newEnd; i < m_end; i += 0x1000) {
- FREE(i);
+ m_pagedir->freeFrame(i);
}
+#else
+ m_process.freePages(newEnd, (m_end - newEnd) / 0x1000);
+#endif
m_end = newEnd;
}
diff --git a/Source/Library/Interface/FSNode.iface.h b/Source/Library/Interface/FSNode.iface.h
index e6c45d3..533b780 100644
--- a/Source/Library/Interface/FSNode.iface.h
+++ b/Source/Library/Interface/FSNode.iface.h
@@ -19,23 +19,24 @@ enum {
#define FNIF_OBJTYPE 0x14
//S : static, GET : get, R : root, FN : fsnode
-#define FNIF_SGETRFN 0
-#define FNIF_SGETCWD 1 //Get current working directory
-#define FNIF_SFIND 2 //Find a node following a path from a node
-#define FNIF_SMKDIR 3 //Makes a directory
-
-#define FNIF_GETNAME 0x10
-#define FNIF_TYPE 0x11
-#define FNIF_GETPARENT 0x12
-#define FNIF_GETLENGTH 0x13
-#define FNIF_GETUID 0x14
-#define FNIF_GETGID 0x15
-#define FNIF_GETPERM 0x16
-#define FNIF_GETPATH 0x17
-#define FNIF_SETCWD 0x18 //Sets node as current working directory
-#define FNIF_REMOVE 0x19
-
-#define FNIF_GETIDXCHILD 0x20 //Get child node from index
-#define FNIF_GETNAMECHILD 0x21 //Get child node from name
+
+#define FNIF_SGETRFN 0 //Get root filesystem node (R) | no arguments
+#define FNIF_SGETCWD 1 //Get current working directory (R) | no arguments
+#define FNIF_SFIND 2 //Find a node following a path from a node (R) | S:filename, R:start_node
+#define FNIF_SMKDIR 3 //Makes a directory (R) | S:filename, R:start_node
+
+#define FNIF_GETNAME 0x10 //Get name of a node (S) | no arguments
+#define FNIF_TYPE 0x11 //Get type of a node (I: NT_*) | no arguments
+#define FNIF_GETPARENT 0x12 //Get parent of a node (R) | no arguments
+#define FNIF_GETLENGTH 0x13 //Get length of contents of a node (I) | no arguments
+#define FNIF_GETUID 0x14 //Get UID for a node (i) | no arguments
+#define FNIF_GETGID 0x15 //Get GID for a node (i) | no arguments
+#define FNIF_GETPERM 0x16 //Get permissions for a node (i) | no arguments
+#define FNIF_GETPATH 0x17 //Get absolute path to node (S) | no arguments
+#define FNIF_SETCWD 0x18 //Sets node as current working directory (v) | no arguments
+#define FNIF_REMOVE 0x19 //Remove node (b) | no arguments
+
+#define FNIF_GETIDXCHILD 0x20 //Get child node from index (R) | i:index
+#define FNIF_GETNAMECHILD 0x21 //Get child node from name (R) | S:name
#endif
diff --git a/Source/Library/Interface/File.iface.h b/Source/Library/Interface/File.iface.h
index e1030b8..bb0fd4b 100644
--- a/Source/Library/Interface/File.iface.h
+++ b/Source/Library/Interface/File.iface.h
@@ -17,17 +17,17 @@ enum {
#define FLIF_OBJTYPE 0x13
-#define FLIF_SOPEN 0x01
+#define FLIF_SOPEN 0x01 //Open a file (R:ressource id of opened file) | S:filename, i:mode (FM_*), r:start_node
-#define FLIF_CLOSE 0x05
-#define FLIF_VALID 0x06
+#define FLIF_CLOSE 0x05 //Close a file (v) | no arguments
+#define FLIF_VALID 0x06 //True if a file is valid (b) | no arguments
-#define FLIF_READ 0x0A
-#define FLIF_WRITE 0x0B
+#define FLIF_READ 0x0A //Read from a file (i:number of bytes read) | i:length, *:data
+#define FLIF_WRITE 0x0B //Write to a file (b) | i:length, *:data
-#define FLIF_SEEK 0x10
-#define FLIF_POSITION 0x11
-#define FLIF_LENGTH 0x12
-#define FLIF_EOF 0x13
+#define FLIF_SEEK 0x10 //Seek to a position in a file (b) | j:position, J:position, i:mode (SM_*)
+#define FLIF_POSITION 0x11 //Get position in a file (I) | no arguments
+#define FLIF_LENGTH 0x12 //Get length of a file (I) | no arguments
+#define FLIF_EOF 0x13 //Are we at end of file (b) | no arguments
#endif
diff --git a/Source/Library/Interface/Process.iface.h b/Source/Library/Interface/Process.iface.h
index cdd6e47..4d3217f 100644
--- a/Source/Library/Interface/Process.iface.h
+++ b/Source/Library/Interface/Process.iface.h
@@ -6,27 +6,27 @@
#define PRIF_OBJTYPE 0x20
//S = static, GET = get, C = current, PR = process
-#define PRIF_SGETCPR 0
-#define PRIF_SRUN 1
-#define PRIF_SWAIT 2
+#define PRIF_SGETCPR 0 //Get current process (R) | no arguments
+#define PRIF_SRUN 1 //Run a new process (R) | S:executable_name
+#define PRIF_SWAIT 2 //Wait for a process to end (i:return value) | R:process to wait for
-#define PRIF_EXIT 0x01
-#define PRIF_ALLOCPAGE 0x02
-#define PRIF_FREEPAGE 0x03
-#define PRIF_GETPID 0x04
-#define PRIF_GETPPID 0x05
+#define PRIF_EXIT 0x01 //Exit from current process (v) | no arguments
+#define PRIF_ALLOCPAGES 0x02 //Allocate frames for pages (v) | i:position, i:count
+#define PRIF_FREEPAGES 0x03 //Free frames for pages (v) | i:position, i:count
+#define PRIF_GETPID 0x04 //Get PID of a process (i) | no arguments
+#define PRIF_GETPPID 0x05 //Get PPID of a process (i) | no arguments
-#define PRIF_ARGC 0x10
-#define PRIF_ARGV 0x11
+#define PRIF_ARGC 0x10 //Get argument count for a process (i) | no arguments
+#define PRIF_ARGV 0x11 //Get argument value for a process (S) | i:argument_index
-#define PRIF_START 0x20
-#define PRIF_AUTODELETE 0x21
-#define PRIF_PUSHARG 0x28
-#define PRIF_SETOUTVT 0x29
-#define PRIF_SETINVT 0x30
+#define PRIF_START 0x20 //Start execution of a child process (v) | no arguments
+#define PRIF_AUTODELETE 0x21 //Set a child to auto-delete itself when it ends (v) | b:does it autodelete?
+#define PRIF_PUSHARG 0x28 //Push an argument to a child process (v) | S:argument
+#define PRIF_SETOUTVT 0x29 //Set output VirtualTerminal for a child process (v) | r:virtual terminal
+#define PRIF_SETINVT 0x30 //Set input VirtualTerminal for a child process (v) | r:virtual terminal
//Authenticate with password/without password (being in group root)
-#define PRIF_AUTHPW 0x40
-#define PRIF_AUTHNOPW 0x41
+#define PRIF_AUTHPW 0x40 //Authenticate current process to a user (b:succeeded?) | S:username, S:password
+#define PRIF_AUTHNOPW 0x41 //Authenticate to a user without password, root only (b:succeeded?) | S:username
#endif
diff --git a/Source/Library/Interface/ReadME.txt b/Source/Library/Interface/ReadME.txt
new file mode 100644
index 0000000..356dd4a
--- /dev/null
+++ b/Source/Library/Interface/ReadME.txt
@@ -0,0 +1,19 @@
+Descriptions of functions are defined in the .iface.h files.
+
+The ????_OBJTYPE defines represent the class identifier for that class.
+The ????_S* defines are IDs for function syscalls : they do not apply to an object
+All the other defines are IDs for method syscalls, that apply to one objec of that type
+
+The description of a function/method is formatted as follows :
+//<role of function/method> (<return type>[:<what is returned>]) | [<arg type>:<arg name> [, ...] ]
+The return type and the arguments type can be one of :
+- v : void (for return type)
+- b : bool (0 = false, anything = true)
+- c : a character
+- S : a pointer to a String object
+- i : an integer
+- I : a pointer to a u64int
+- j/J : lower/higher half of a u64int
+- r : an identifier for any ressource object
+- R : an identifier for a ressource object, but of same class
+- * : a pointer to some space (u8int*)
diff --git a/Source/Library/Interface/Sys.iface.h b/Source/Library/Interface/Sys.iface.h
index bebab41..072fe7b 100644
--- a/Source/Library/Interface/Sys.iface.h
+++ b/Source/Library/Interface/Sys.iface.h
@@ -3,10 +3,10 @@
#define SYIF_IFID 0xFF
-#define SYIF_HALT 0x1
-#define SYIF_REBOOT 0x2
-#define SYIF_UPTIME 0x3
-#define SYIF_TOTALRAM 0x4
-#define SYIF_FREERAM 0x5
+#define SYIF_HALT 0x1 //Halt system, root only (v) | no arguments
+#define SYIF_REBOOT 0x2 //Reboot system, root only (v) | no arguments
+#define SYIF_UPTIME 0x3 //Get uptime (i) | no arguments
+#define SYIF_TOTALRAM 0x4 //Get toal amount of RAM in Ko (i) | no argmuents
+#define SYIF_FREERAM 0x5 //Get free amount of RAM in Ko (i) | no arguments
#endif
diff --git a/Source/Library/Interface/Thread.iface.h b/Source/Library/Interface/Thread.iface.h
index 0dac2e1..68b0c58 100644
--- a/Source/Library/Interface/Thread.iface.h
+++ b/Source/Library/Interface/Thread.iface.h
@@ -4,9 +4,9 @@
#define THIF_OBJTYPE 0x21
//S = static, GET = get, C = current, TH = thread
-#define THIF_SGETCTH 0
+#define THIF_SGETCTH 0 //Get current thread (R) | no arguments
-#define THIF_SLEEP 0x01
-#define THIF_FINISH 0x02
+#define THIF_SLEEP 0x01 //Make thread sleep (v) | i:time in msecs
+#define THIF_FINISH 0x02 //Make thread finish (v) | i:return_value
#endif
diff --git a/Source/Library/Interface/VirtualTerminal.iface.h b/Source/Library/Interface/VirtualTerminal.iface.h
index c7e75e8..e0f59d5 100644
--- a/Source/Library/Interface/VirtualTerminal.iface.h
+++ b/Source/Library/Interface/VirtualTerminal.iface.h
@@ -4,24 +4,25 @@
#define VTIF_OBJTYPE 0x10
//S = static, GET = get, PR = process, IN/OUT : in/out, VT = virtualterminal
-#define VTIF_SGETPRINVT 6
-#define VTIF_SGETPROUTVT 7
+#define VTIF_SGETPRINVT 6 //Get process input virtual terminal (R) | no arguments
+#define VTIF_SGETPROUTVT 7 //Get process output virtual terminal (R) | no arguments
-#define VTIF_PUT 0x01
-#define VTIF_WRITEHEX 0x02
-#define VTIF_WRITEDEC 0x03
-#define VTIF_WRITE 0x04
+#define VTIF_PUT 0x01 //Put one character to virtual terminal (v) | c:character
+#define VTIF_WRITEHEX 0x02 //Write a number in hexadecimal (v) | i:number
+#define VTIF_WRITEDEC 0x03 //Write a number in decimal (v) | j:number, J:number
+#define VTIF_WRITE 0x04 //Write a string (v) | S:string
-#define VTIF_READLINE 0x05
-#define VTIF_GETKEYPRESS 0x06 //Takes two flags : 1<<0 = show, 1<<1 = block
+#define VTIF_READLINE 0x05 //Reads a line from virtual terminal (S) : b:show?
+#define VTIF_GETKEYPRESS 0x06 //Get a keypress from virtual terminal (*) : i:flags
+ //Takes two flags : 1<<0 = show, 1<<1 = block
-#define VTIF_SETCOLOR 0x10
-#define VTIF_SETCSRLINE 0x11
-#define VTIF_SETCSRCOL 0x12
-#define VTIF_ISBOXED 0x13
+#define VTIF_SETCOLOR 0x10 //Set text color (v) | i:foreground_color, i:backgrond_color
+#define VTIF_SETCSRLINE 0x11 //Set cursor line (v) | i:line
+#define VTIF_SETCSRCOL 0x12 //Set cursor column (v) | i:column
+#define VTIF_ISBOXED 0x13 //Is VT boxed ? (b) | no arguments
-#define VTIF_GETHEIGHT 0x1A
-#define VTIF_GETWIDTH 0x1B
-#define VTIF_LOCATE 0x1C //Takes line, col and sets cursor position
+#define VTIF_GETHEIGHT 0x1A //Get VT width (i) | no arguments
+#define VTIF_GETWIDTH 0x1B //Get VT height (i) | no arguments
+#define VTIF_LOCATE 0x1C //Sets cursor position (v) | i:line, i:column
#endif
diff --git a/Source/Library/Userland/Binding/Process.class.h b/Source/Library/Userland/Binding/Process.class.h
index 948d670..523be79 100644
--- a/Source/Library/Userland/Binding/Process.class.h
+++ b/Source/Library/Userland/Binding/Process.class.h
@@ -21,11 +21,11 @@ class Process : public RessourceCaller {
void exit() {
doCall(PRIF_EXIT);
}
- void allocPage(u32int pos) {
- doCall(PRIF_ALLOCPAGE, pos);
+ void allocPages(u32int pos, u32int count) {
+ doCall(PRIF_ALLOCPAGES, pos, count);
}
- void freePage(u32int pos) {
- doCall(PRIF_FREEPAGE, pos);
+ void freePages(u32int pos, u32int count) {
+ doCall(PRIF_FREEPAGES, pos, count);
}
u32int getPid() {
return doCall(PRIF_GETPID);