Commit Graph

263 Commits

Author SHA1 Message Date
Justin C. Miller
f7558e3d18 Implement fast syscall/sysret for sytem calls 2019-03-13 23:51:29 -07:00
Justin C. Miller
97e8f2c69a Add get_gsbase() 2019-03-13 22:49:20 -07:00
Justin C. Miller
49bdf47514 Remove segments from push_all 2019-03-13 22:45:02 -07:00
Justin C. Miller
870ca1db45 Allow debug option to be communicated at boot 2019-03-11 03:04:57 -07:00
Justin C. Miller
74a5c301f8 Add guid_device_path GUIDs 2019-03-10 23:35:23 -07:00
Justin C. Miller
722ee4c52c Recycle old initial pml4 2019-03-10 00:51:39 -08:00
Justin C. Miller
67b9f45004 Offset-map the entire offset region with 1G pages
Instead of building nested page tables for the offset region, just
offset map the entire thing into kernel memory with one PDP mapping
1GiB large pages. This is more efficient and avoids the "need a
page table to map in a page table" dependency loop.
2019-03-09 14:55:48 -08:00
Justin C. Miller
2035fffa1c Fix loading large process images.
2MiB large pages were being used for any large page mapping, but the
page manager doesn't correctly handle them everywhere yet. Now only
allow them for offset pointers (eg MMIO space) that will never be
unmapped.
2019-03-09 13:10:10 -08:00
Justin C. Miller
97ac3c09fa Implement initial fork syscall 2019-03-09 12:18:21 -08:00
Justin C. Miller
241e1dacb0 Consolidate testing memory setup 2019-03-07 23:53:38 -08:00
Justin C. Miller
ac19d3f532 Allow page table copying and unmapping
Lots of rearranging in page_manager as well, moving constants out as
well as helper structs.
2019-03-03 01:52:21 -08:00
Justin C. Miller
194527e0fe Fix address-marking bugs
* Non-blocksize-aligned regions could fail to be found. Have the
  bootloader load them aligned.
* Consolidating used frame blocks in the bootstrap means these would
  have been impossible to free as address space
* mark_permanent wasn't actually removing blocks from the free list
2019-03-03 01:42:32 -08:00
Justin C. Miller
28cf5562ac Use the address_manager to place allocations 2019-02-28 00:37:00 -08:00
Justin C. Miller
8cdc39fdee Switch page_manager to use frame_allocator.
Removed the frame allocation logic from page_manager and replaced it
with using an instance of frame_allocator instead. This had several
major ripple effects:

- memory_initalize() had to change to support this new world
  - Where to map used blocks is now passed as a flag, since blocks don't
    track their virtual address anymore
  - Instead of the complicated "find N contiguous pages that can be
    mapped in with one page table", we now just have the bootloader give
    us some (currently 64) pages to use both for tables and scratch
    space.
  - frame_allocator initialization was split into two steps to allow
    mapping used blocks before std::move()ing them over
2019-02-28 00:37:00 -08:00
Justin C. Miller
626eec4a31 Frame allocator class added 2019-02-28 00:37:00 -08:00
Justin C. Miller
5901237fee Genericize buddy allocator 2019-02-28 00:37:00 -08:00
Justin C. Miller
f9d964cccb Adding address manager 2019-02-28 00:37:00 -08:00
Justin C. Miller
a9ac30b991 Allow heap_manager to use non-contiguous blocks.
* Heap manager can now manage non-contiguous blocks of memory (currently
  all sized at the max block size only)
* Fix a bug where heap manager would try to buddy-merge max-sized blocks
2019-02-28 00:37:00 -08:00
Justin C. Miller
bbd31929ba Rename memory_manager to heap_manager 2019-02-28 00:37:00 -08:00
Justin C. Miller
341ba5146a Forgot to comment third arg for gdt_write 2019-02-17 23:38:40 -08:00
Justin C. Miller
aca442ee87 First pass at message syscalls 2019-02-07 18:19:22 -08:00
Justin C. Miller
8e85ae5318 Added getpid system call 2019-02-07 17:52:57 -08:00
Justin C. Miller
8c32471e0d Pass CPU state as a pointer
Previously CPU statue was passed on the stack, but the compiler is
allowed to clobber values passed to it on the stack in the SysV x86 ABI.
So now leave the state on the stack but pass a pointer to it into the
ISR functions.
2019-02-07 17:47:42 -08:00
Justin C. Miller
863e5bda15 Turning console into a class 2019-02-04 00:48:18 -08:00
Justin C. Miller
d19cedb12a adding kernel crti/crtn but ctors/dtors not called yet 2019-02-03 18:59:09 -08:00
Justin C. Miller
579f6f64e6 First step of moving bootloader to C++ 2019-02-03 01:38:12 -08:00
Justin C. Miller
38a1197d9e Removing old waf build scripts and vendored libcxx 2019-02-02 21:39:19 -08:00
Justin C. Miller
bc01a37452 Ninja-based buildsystem now building a running kernel! 2019-02-02 21:35:39 -08:00
Justin C. Miller
a1fe745a53 Changing to __POPCORN__ for defining code that is host-only 2019-02-02 14:44:35 -08:00
Justin C. Miller
7e1933d79b Give makerd a cwd argument, and upgrade cpptoml 2019-02-02 12:18:20 -08:00
Justin C. Miller
0f8efdb55e Moving to a ninja-based build system 2019-02-02 02:59:45 -08:00
Justin C. Miller
523d0b3b8c sysroot and cross-compiler based build WIP 2019-01-17 00:51:45 -08:00
Justin C. Miller
591ca7c83c libc WIP 2018-09-24 11:13:18 -07:00
Justin C. Miller
229c1e4965 Moved cpptoml to just makerd's includes 2018-09-21 20:36:01 -07:00
Justin C. Miller
d8399e3c07 Fix for page faults under KVM
Under KVM we were hitting what look like out-of-order and/or issues
during initialization when writing to the page tables and then
immediately writing to the mapped memory.  Adding a memory barrier and
an io_wait() in memory_bootstrap.cpp fixed it.
2018-09-21 20:34:26 -07:00
Justin C. Miller
cef0a71bce Use uintptr_t instead of addr_t
They're never actually going to change independently, and it's also
brining in kutil headers more places than they should be.
2018-09-20 09:37:30 -07:00
Justin C. Miller
a9d72b8102 Fixing APIC timer log message 2018-09-18 17:33:11 -07:00
Justin C. Miller
d469482a7f Better spurious interrupt handling 2018-09-16 23:50:54 -07:00
Justin C. Miller
c67c1bd6a2 Give processes multiple quanta before rescheduling 2018-09-16 23:34:42 -07:00
Justin C. Miller
5e6769036c APIC timer calibration
Now the APIC timer is calibrated against the PIT, and the interval for
timer_enable takes a number of microseconds instead of raw ticks and a
divisor.
2018-09-16 18:56:01 -07:00
Justin C. Miller
482b9f50fc Initial process waiting/waking
Processes can now wait on signals/children/time. There is no clock
currently so "time" is just a monotonically increating tick count. Added
a SLEEP syscall to test this waiting/waking.
2018-09-16 12:22:52 -07:00
Justin C. Miller
f4e7eaeb40 Fixing #include error in linked_list.h 2018-09-16 12:20:14 -07:00
Justin C. Miller
8c2ff33c40 Reduce number of DEbuG syscalls in nulldrv 2018-09-15 00:40:30 -07:00
Justin C. Miller
1308864061 MSR and syscall changes
- Moved MSR code to separate files with an enum class
- Implemented syscall_enable in C++ using new MSR calls
2018-09-15 00:37:49 -07:00
Justin C. Miller
62c559043d Pause syscall and int 0xee interrupt syscalls
The syscall/sysret instructions don't swap stacks. This was bad but
passable until syscalls caused the scheduler to run, and scheduling a
task that paused due to interrupt.

Adding a new (hopefully temporary) syscall interrupt `int 0xee` to allow
me to test syscalls without stack issues before I tackle the
syscall/sysret issue.

Also implemented a basic `pause` syscall that causes the calling process
to become unready. Because nothing can wake a process yet, it never
returns.
2018-09-12 20:59:08 -07:00
Justin C. Miller
c2f85ce61b Some enum_bitfield helper operators
Added:
  set += flag -> set = set | flag
  set -= flag -> set = set & ~flag
  set && flag -> (set & flag) == flag
2018-09-12 20:57:15 -07:00
Justin C. Miller
5808599005 Getting rid of 'boogity!'.. end of an era.
Since I'm doing a lot of work on task scheduling, 'boogity!' simply
isn't the "we're all good and we're done!" message that it used to be.
2018-09-12 20:51:50 -07:00
Justin C. Miller
fafe582802 Initial priority-based scheduler
- Scheduler now has multiple linked_lists of processes at different
  priorities
- Process structure improvements
- scheduler::tick() and scheduler::schedule() separation
2018-09-11 22:37:00 -07:00
Justin C. Miller
593cda3ee8 Convert page_block to use kutil::linked_list
- Created a new linked_list-based slab allocator
- Simplified memory bootstrap code by using the slab allocator and
  linked_lists
2018-09-11 20:46:48 -07:00
Justin C. Miller
d5c44645eb New templatized linked_list collection
Also updated tests to work with memory changes
2018-09-09 15:32:10 -07:00