diff options
-rw-r--r-- | Source/Kernel/TaskManager/Process-sc.class.cpp | 22 | ||||
-rw-r--r-- | Source/Library/Common/Heap.class.cpp | 12 | ||||
-rw-r--r-- | Source/Library/Interface/Process.iface.h | 4 | ||||
-rw-r--r-- | Source/Library/Userland/Binding/Process.class.h | 8 |
4 files changed, 23 insertions, 23 deletions
diff --git a/Source/Kernel/TaskManager/Process-sc.class.cpp b/Source/Kernel/TaskManager/Process-sc.class.cpp index e5910af..6085e3f 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_ALLOCPAGES, &Process::allocPagesSC), - CALL1(PRIF_FREEPAGES, &Process::freePagesSC), + CALL2(PRIF_ALLOCPAGES, &Process::allocPagesSC), + CALL2(PRIF_FREEPAGES, &Process::freePagesSC), CALL0(PRIF_GETPID, &Process::getPid), CALL0(PRIF_GETPPID, &Process::getPpid), CALL0(PRIF_GETUID, &Process::getUid), @@ -51,12 +51,13 @@ u32int Process::exitSC() { return 0; } -u32int Process::allocPagesSC(u32int pos, u32int count) { +u32int Process::allocPagesSC(u32int pos, u32int end) { if (Task::currProcess() != this) return 1; if ((pos & 0x00000FFF) != 0) pos = (pos & 0xFFFFF000) + 0x1000; - if (pos + (count - 1) * 0x1000 >= 0xC0000000) return 1; - for (u32int i = 0; i < count; i++) - m_pagedir->allocFrame(pos + (i * 0x1000), true, true); + if ((end & 0x00000FFF) != 0) end = (end & 0xFFFFF000) + 0x1000; + if (end - 1 >= 0xC0000000) return 1; + for (u32int i = pos; i < end; i += 0x1000) + m_pagedir->allocFrame(i, true, true); return 0; } @@ -75,12 +76,13 @@ u32int Process::argvSC(u32int idx) { return (u32int) - 1; } -u32int Process::freePagesSC(u32int pos, u32int count) { +u32int Process::freePagesSC(u32int pos, u32int end) { if (Task::currProcess() != this) return 1; if ((pos & 0x00000FFF) != 0) pos = (pos & 0xFFFFF000) + 0x1000; - if (pos + (count - 1) * 0x1000 >= 0xC0000000) return 1; - for (u32int i = 0; i < count; i++) - m_pagedir->freeFrame(pos + (i * 0x1000)); + if ((end & 0x00000FFF) != 0) end = (end & 0xFFFFF000) + 0x1000; + if (end - 1 >= 0xC0000000) return 1; + for (u32int i = pos; i < end; i += 0x1000) + m_pagedir->freeFrame(i); return 0; } diff --git a/Source/Library/Common/Heap.class.cpp b/Source/Library/Common/Heap.class.cpp index 2491e00..7a6c6d8 100644 --- a/Source/Library/Common/Heap.class.cpp +++ b/Source/Library/Common/Heap.class.cpp @@ -34,16 +34,14 @@ void Heap::create(u32int start, u32int size, u32int idxsize) { m_pagedir = pagedir; m_user = user; m_rw = rw; -#endif //Allocate frames for heap -#ifdef THIS_IS_MELON_KERNEL - for (u32int i = m_start ; i < m_end; i += 0x1000) { + for (u32int i = 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); + m_process.allocPages(start, m_end); #endif m_index.data = (heap_header_t **)start; //Set index start. start == start of all heap @@ -73,11 +71,11 @@ void Heap::expand(u32int quantity) { u32int newEnd = m_end + quantity; #ifdef THIS_IS_MELON_KERNEL - for (u32int i = m_start ; i < m_end; i += 0x1000) { + for (u32int i = m_end ; i < newEnd; i += 0x1000) { m_pagedir->allocFrame(i, m_user, m_rw); } #else - m_process.allocPages(m_start, (m_end - m_start) / 0x1000); + m_process.allocPages(m_end, newEnd); #endif heap_footer_t *last_footer = (heap_footer_t*) (m_end - sizeof(heap_footer_t)); @@ -136,7 +134,7 @@ void Heap::contract() { //Automatically work out how much we can contract m_pagedir->freeFrame(i); } #else - m_process.freePages(newEnd, (m_end - newEnd) / 0x1000); + m_process.freePages(newEnd, m_end); #endif m_end = newEnd; diff --git a/Source/Library/Interface/Process.iface.h b/Source/Library/Interface/Process.iface.h index b387801..261afa7 100644 --- a/Source/Library/Interface/Process.iface.h +++ b/Source/Library/Interface/Process.iface.h @@ -11,8 +11,8 @@ #define PRIF_SWAIT 2 //Wait for a process to end (i:return value) | R:process to wait for #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_ALLOCPAGES 0x02 //Allocate frames for pages (v) | i:start, i:end +#define PRIF_FREEPAGES 0x03 //Free frames for pages (v) | i:start, i:end #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_GETUID 0x06 //Get UID of a process (i) | no arguments diff --git a/Source/Library/Userland/Binding/Process.class.h b/Source/Library/Userland/Binding/Process.class.h index 1a1481f..2200f59 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 allocPages(u32int pos, u32int count) { - doCall(PRIF_ALLOCPAGES, pos, count); + void allocPages(u32int pos, u32int end) { + doCall(PRIF_ALLOCPAGES, pos, end); } - void freePages(u32int pos, u32int count) { - doCall(PRIF_FREEPAGES, pos, count); + void freePages(u32int pos, u32int end) { + doCall(PRIF_FREEPAGES, pos, end); } u32int getPid() { return doCall(PRIF_GETPID); |