vm: pte: Remove redundant code and add comments

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>
x86: mm: pte: Fix some issues with atomics

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>
mm: vm: Add virtual page allocator code

The code hasn't been tested, there's a lot more work to be done on that
front. At the same time, no thought has even gone into a de-allocator if
that ever proves to be necessary.

Be careful using this code, or wait for tests and fixes to be written.

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>
Merge branch 'testing' into page_alloc

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>

Conflicts:
	.gitignore
vm: page_alloc: Add page alloc ref count

If references to these physical ranges need to be shared, they are to be
reallocated. This makes keeping track of these shared pages a lot more
simple because the allocator now maintains a reference count.

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>
mm: vm: Add virtual page allocation and freeing

Whenever the slab allocator is in need of more memory, it can rely upon
these functions in order to provide it with more memory.

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>
mm: page_alloc: Fix bug in page freeing

In the reference count, the page freeing code assumed that the reference
count was to be decreased. However, since the reference count happens in
negative numbers, the value was to be increased.

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>
link: Make the segments PAGE_ALLOC_FACTOR aligned

In order to keep easy track of the location of the segments in the
kernel, which are allocated using PAGE_ALLOC_FACTOR, we are resizing
them to conform to this.

PAGE_ALLOC_FACTOR currently stands at 16K, not 4K like a page would be.
This is because although the allocation is less granular, the data
mapping out the allocated and free bits of memory is quite a bit
smaller.

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>
mm: vm: Align all segments to 16K

All segments are to be aligned to 16K as it makes allocation of physical
pages, quite the bit easier.

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>
mm: vm: Start testing the VM system

Maybe it could have been handier to do this a little earlier, but better
late than never, my mum always says.

The most simple test you can think of, a plain data dump. I think I
already have the first bug this way. That'll be for the next commit
though.

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>
mm: vm: Fix bugs regarding segment linking

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>
mm: vm: Make data from heap segment allocatable

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>
mm: vm: Add segment grow and fix atomicity

Segments can now be grown, but not overlap. This sets the requirement
for some mutexes to be locked. If two segments are grown, in parallel,
this might create a deadlock.

I made an attempt at preventing it, but I'm not too certain on my
successes with that, as there still is space for a dining phylosophers
problem.

If the mutexes are locked too quickly I think this might also deadlock
against a segment removal.

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>
mm: vm: Attempt to remove deadlocks

Now I want to be clear here, that I still don't believe I have them all,
but I certainly got quite the way there this time.

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>
mm: vm: Fix thread safety and fix segment removal

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>
mm: vm: Fix list issue with range descriptors

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>
mm: vm: Add page allocate and page free function

Now if a slab requires pages, it can just approach
vm_get_kernel_heap_pages and get its data (PAGE_ALLOC_FACTOR aligned).

Freeing is done through the vm_free_kernel_heap_pages function and will
keep automatic track of the size of those allocated regions.

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>
mm: vm: Fix range merging issue

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>
driver: out: text: Deprecate println

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>
mm: vm: Move allocation out to its very own file

Virtual range allocations were cluttering up the operations done on the
actual segments. Those got so much in the way to me I decided to move
them out to their own file.

Signed-off-by: Bart Kuivenhoven <bemkuivenhoven@gmail.com>