Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

createSegment now takes an array instead of a pointer and a length. a…

…lso, C virtual heap size is now 512 GB
  • Loading branch information...
commit 15dc66c760de60930359c0ebd900f343b046eda4 1 parent 1601639
@wolfwood wolfwood authored
View
24 kernel/arch/x86_64/architecture/vm.d
@@ -35,28 +35,28 @@ public:
// Create a new segment that will fit the indicated size
// into the global address space.
- ubyte[] createSegment(ubyte* location, ulong size, AccessMode flags) {
+ ubyte[] createSegment(ubyte[] location, AccessMode flags) {
bool success;
- uint pagelevel = sizeToPageLevel(size);
+ uint pagelevel = sizeToPageLevel(location.length);
switch(pagelevel){
case 1:
// create the segment in the AddressSpace
- success = Paging.createGib!(PageLevel!(1))(location, flags);
+ success = Paging.createGib!(PageLevel!(1))(location.ptr, flags);
break;
case 2:
- success = Paging.createGib!(PageLevel!(2))(location, flags);
+ success = Paging.createGib!(PageLevel!(2))(location.ptr, flags);
break;
case 3:
- success = Paging.createGib!(PageLevel!(3))(location, flags);
+ success = Paging.createGib!(PageLevel!(3))(location.ptr, flags);
break;
case 4:
- success = Paging.createGib!(PageLevel!(4))(location, flags);
+ success = Paging.createGib!(PageLevel!(4))(location.ptr, flags);
break;
}
if(success){
- return location[0 .. size];
+ return location;
}else{
return null;
}
@@ -118,13 +118,13 @@ public:
synchronized ubyte* mapStack(PhysicalAddress physAddr) {
if(stackSegment is null){
- stackSegment = findFreeSegment().ptr;
- createSegment(stackSegment, oneGB, AccessMode.Writable|AccessMode.AllocOnAccess);
+ stackSegment = findFreeSegment();
+ createSegment(stackSegment, AccessMode.Writable|AccessMode.AllocOnAccess);
}
- stackSegment += Paging.PAGESIZE;
+ stackSegment = stackSegment[Paging.PAGESIZE..$];
- return Paging.mapRegion(stackSegment, physAddr, Paging.PAGESIZE).ptr;
+ return Paging.mapRegion(stackSegment.ptr, physAddr, Paging.PAGESIZE).ptr;
}
// --- OLD --- //
@@ -137,5 +137,5 @@ public:
}
private:
- ubyte* stackSegment;
+ ubyte[] stackSegment;
}
View
5 kernel/core/initprocess.d
@@ -119,8 +119,9 @@ private:
//kprintfln!("Init found at module index {} with start {} and length{}")(idx, System.moduleInfo[idx].start, System.moduleInfo[idx].length);
- ubyte[] segmentBytes =
- VirtualMemory.createSegment(cast(ubyte*)(segidx*oneGB), oneGB, AccessMode.User|AccessMode.Writable|AccessMode.AllocOnAccess|AccessMode.Executable);
+ ubyte[] segmentBytes = (cast(ubyte*)(segidx*oneGB))[0..oneGB];
+
+ VirtualMemory.createSegment(segmentBytes, AccessMode.User|AccessMode.Writable|AccessMode.AllocOnAccess|AccessMode.Executable);
VirtualMemory.mapRegion(segmentBytes.ptr, System.moduleInfo[idx].start, System.moduleInfo[idx].length);
View
2  kernel/core/syscall.d
@@ -29,7 +29,7 @@ public:
// ubyte[] location = create(ubyte* location, ulong size, int mode);
SyscallError create(out ubyte[] ret, CreateArgs* params) {
// Create a new resource.
- ret = VirtualMemory.createSegment(params.location, params.size, params.mode);
+ ret = VirtualMemory.createSegment(params.location, params.mode);
return SyscallError.Failcopter;
}
View
2  kernel/dev/console.d
@@ -51,7 +51,7 @@ public:
_segment = VirtualMemory.findFreeSegment(true, ramSize+vramSize);
- ubyte[] vid = VirtualMemory.createSegment(_segment.ptr, _segment.length, AccessMode.Writable|AccessMode.AllocOnAccess|AccessMode.Device);
+ ubyte[] vid = VirtualMemory.createSegment(_segment, AccessMode.Writable|AccessMode.AllocOnAccess|AccessMode.Device);
MetaData* videoMetaData = cast(MetaData*)vid.ptr;
*videoMetaData = info;
View
2  kernel/dev/keyboard.d
@@ -17,7 +17,7 @@ class Keyboard {
ErrorVal initialize() {
segment = VirtualMemory.findFreeSegment(true, BUFFER_SIZE);
- _buffer = cast(short[])VirtualMemory.createSegment(segment.ptr, BUFFER_SIZE, AccessMode.DefaultKernel);
+ _buffer = cast(short[])VirtualMemory.createSegment(segment, AccessMode.DefaultKernel);
_writeOffset = cast(ushort*)_buffer.ptr;
*_writeOffset = 0;
View
2  kernel/mem/bitmap.d
@@ -29,7 +29,7 @@ ErrorVal initialize() {
totalPages = System.memory.length / VirtualMemory.pagesize();
// Get a gib for the page allocator
- bitmapGib = cast(ulong*)VirtualMemory.createSegment(VirtualMemory.findFreeSegment().ptr, oneGB, AccessMode.Writable|AccessMode.AllocOnAccess).ptr;
+ bitmapGib = cast(ulong*)VirtualMemory.createSegment(VirtualMemory.findFreeSegment(), AccessMode.Writable|AccessMode.AllocOnAccess).ptr;
// Calculate how much we need for the bitmap.
// 8 bits per byte, 8 bytes for ulong.
View
5 libos/fs/minfs.d
@@ -44,7 +44,7 @@ class MinFS{
// this creates the 'SuperSegment', the super-block-like known-location which also happens to contain all the fs metadata (filenames)
void format(){
- Syscall.create(createAddr(0,0,0,257), oneGB, AccessMode.User|AccessMode.Writable|AccessMode.Global|AccessMode.AllocOnAccess);
+ Syscall.create(createAddr(0,0,0,257)[0..oneGB], AccessMode.User|AccessMode.Writable|AccessMode.Global|AccessMode.AllocOnAccess);
hdr = cast(Header*)createAddr(0,0,0,257);
@@ -66,8 +66,7 @@ class MinFS{
mode |= AccessMode.AllocOnAccess;
}
- //ubyte[]
- Syscall.create(f.ptr, f.length, mode | AccessMode.Global);
+ Syscall.create(f, mode | AccessMode.Global);
}
}else{
Syscall.map(null, f, null, mode | AccessMode.Global);
View
24 libos/libdeepmajik/umm.d
@@ -2,29 +2,19 @@ module libos.libdeepmajik.umm;
import Syscall = user.syscall;
+import user.environment;
import user.types;
class UserspaceMemoryManager{
static:
ubyte[] stacks;
- ubyte* stackGib = cast(ubyte*)(254UL << ((9*3) + 12));
const uint pageSize = 4096;
synchronized void initialize(){
- stacks = Syscall.create(stackGib, 1024*1024*1024, AccessMode.User|AccessMode.Writable|AccessMode.AllocOnAccess);
+ stacks = Syscall.create(findFreeSegment(), AccessMode.User|AccessMode.Writable|AccessMode.AllocOnAccess);
}
synchronized ubyte* getPage(bool spacer = false){
- //pageStack -= 4096;
-
- //ubyte* temp = pageStack;
-
- //allocPage(cast(ubyte*)pageStack);
-
- //if(spacer){pageStack -= 4096;}
-
- //return temp;
-
if(stacks.length < pageSize){return null;}
ubyte[] stack = stacks[(length - pageSize).. length];
@@ -41,17 +31,11 @@ class UserspaceMemoryManager{
return;
}
- // XXX: heap is limited to 4 GB
ubyte[] initHeap(){
ulong i;
- ubyte[] foo
- = Syscall.create(cast(ubyte*)(20*oneGB), 1024*1024*1024, AccessMode.User|AccessMode.Writable|AccessMode.AllocOnAccess);
-
- for(i = 1; i < 4; i++){
- Syscall.create(cast(ubyte*)((20+1)*oneGB), 1024*1024*1024, AccessMode.User|AccessMode.Writable|AccessMode.AllocOnAccess);
- }
+ ubyte[] foo = findFreeSegment(false, 512*oneGB);
- foo = foo.ptr[0..(i*oneGB)];
+ Syscall.create(foo, AccessMode.User|AccessMode.Writable|AccessMode.AllocOnAccess);
return foo;
}
View
4 user/ipc.d
@@ -119,9 +119,9 @@ template populateChild(T){
version(KERNEL){
// kernel only executes init once, so its OK not to copy
}else{
- ubyte* g = findFreeSegment(false).ptr;
+ ubyte[] g = findFreeSegment(false);
- Syscall.create(g, oneGB, AccessMode.Writable|AccessMode.User|AccessMode.Executable|AccessMode.AllocOnAccess);
+ Syscall.create(g, AccessMode.Writable|AccessMode.User|AccessMode.Executable|AccessMode.AllocOnAccess);
// XXX: instead of copying the whole thing we should only be duping the r/w data section
uint len = *(cast(ulong*)f.ptr) + ulong.sizeof;
View
3  user/syscall.d
@@ -41,8 +41,7 @@ alias Tuple! (
) SyscallRetTypes;
struct CreateArgs {
- ubyte* location;
- ulong size;
+ ubyte[] location;
AccessMode mode;
}
Please sign in to comment.
Something went wrong with that request. Please try again.