1
0
mirror of https://github.com/taigrr/gopher-os synced 2025-01-18 04:43:13 -08:00

46 Commits

Author SHA1 Message Date
Achilleas Anagnostopoulos
7deeab3cbc vmm: switch exception handling to use the new gate package 2018-06-01 08:19:39 +01:00
Achilleas Anagnostopoulos
7b12fbd940 gate: provide cleaner implementation of arch-specific gate management code 2018-06-01 08:19:39 +01:00
Achilleas Anagnostopoulos
2b8bf98b55 irq: remove old interrupt handling implementation 2018-05-31 21:21:04 +01:00
Achilleas Anagnostopoulos
e67e2644e2 mm: refactor package layout for the memory management code
Summary of changes:
- kernel/mem renamed to kernel/mm
- consolidated page/frame defs into one file which now lives in the
kernel/mm package and is referenced by both pmm and vmm pkgs
- consolidated parts of the vmm code (e.g. PDT+PTE)
- memcopy/memset helpers moved to the kernel package
- physical allocators moved to the kernel/mm/pmm package
- break vmm -> pmm pkg dependency by moving AllocFrame() into the mm
package.
2018-05-28 08:16:26 +01:00
Achilleas Anagnostopoulos
340b129e37 multiboot: move package outside the kernel package
Multiboot does not need to be part of the kernel so it has been moved
out.
2018-05-28 08:15:42 +01:00
Achilleas Anagnostopoulos
f1cf7466c7 Revert "kfmt: fix bug where calls to copy() resulted in garbage being copied"
This reverts commit 8f04deadc1f1620dbd0aaea07f04a6c7f82f58c0.

The actual issue was triggered by a memory corruption due to the fact
that the exception handling gate code did not preserve XMM regs.
2018-04-27 19:26:08 +01:00
Achilleas Anagnostopoulos
8f04deadc1 kfmt: fix bug where calls to copy() resulted in garbage being copied
The bug manifested itself as a series of null bytes appearing to the
tty device when the ring buffer gets linked to it and its contents are
flushed to the tty.

Using gdb, I was able to track the problem into the ringbuf's Read
method and specifically to the call to copy(). I have replaced the call
with a for loop that the compiler would anyway optimize into a rep stosb
or equivalent asm instruction.
2018-03-28 07:25:52 +01:00
Achilleas Anagnostopoulos
8d0c44921b goruntime: split bootstrap symbols into conditionally compiled files
Due to some changes in the runtime init functions between go 1.7 and
later versions (e.g. runtime.modulesInit() defined after go 1.7), the
kernel code that bootstraps the go runtime had to be split into separate
files which are conditionally compiled using +build flags.
2018-03-23 07:22:32 +00:00
Achilleas Anagnostopoulos
76f7869f57 vmm: fix some lint warnings (error not checked) 2018-03-22 18:56:28 +00:00
Achilleas Anagnostopoulos
d082a7473a vmm: handle mapping of kernel ELF sections that are not page aligned
The code responsible for mapping the kernel sections worked under the
assumption that the linker would align all sections on a page boundary.
To figure out the page extents for a particular section, the
implementation would round the section VMA down to the nearest page and
add to that the section length rounded up to the nearest page size.

However, some sections (e.g. noptrbss) use 32 byte alignment. Depending
on the section length, the original implementation could in some cases
skip mapping of the last page in the section which would cause a page
fault when its contents were accessed.

The fix for this issue is quite simple: calculate the end page by
rounding up (section start addr + section length) to the next page.
2018-03-22 18:56:13 +00:00
Achilleas Anagnostopoulos
7d959af0a9 acpi: import and register ACPI driver with hal 2017-08-28 07:28:31 +01:00
Achilleas Anagnostopoulos
7bcaf0ee8d vmm: implement identity mapping function for contiguous physical mem regions
vmm.IdentityMapRegion can be used by device drivers that want to
establish an identity mapping for a contiguous physical memory block in
order to access some hardware or table.
2017-08-28 07:28:04 +01:00
Achilleas Anagnostopoulos
0a271b206b pmm: implement FrameFromAddress
This is equivalent to vmm.PageFromAddress but returns back a pmm.Frame
2017-08-28 07:28:04 +01:00
Achilleas Anagnostopoulos
b53912757c Refactor hal code to use preferred driver detection order 2017-07-18 08:27:50 +01:00
Achilleas Anagnostopoulos
37e32d9960 Provide correct implementation for cpu.FlushTLBEntry
The previous version worked under qemu (or qemu does not implement TLB
caching) but caused an unrecoverable page fault when running under
virtualbox.
2017-07-15 17:25:04 +01:00
Achilleas Anagnostopoulos
66d471f442 Defer kernel panic when Kmain returns 2017-07-14 08:05:59 +01:00
Achilleas Anagnostopoulos
ccba8877ce Enable support for deferred calls 2017-07-14 08:05:54 +01:00
Achilleas Anagnostopoulos
4af2ed62a0 Display the best-fit logo on logo-capable console devices
Logos can be disabled by passing the "consoleLogo=off" boot command line
parameter.
2017-07-13 23:35:20 +01:00
Achilleas Anagnostopoulos
540f288e61 Select appropriate font for console devices with font support
The hal package automatically selects the best font from the list of
available fonts based on the console dimensions and the font priorities. The font
selection can be overriden by passing the "consoleFont" boot commandline
parameter to the kernel (e.g. consoleFont=terminus8x16)
2017-07-13 23:35:20 +01:00
Achilleas Anagnostopoulos
6195f3fc3b Setup a more granular PDT based on the ELF image section addresses 2017-07-13 06:35:22 +01:00
Achilleas Anagnostopoulos
cc4364f55c Pass the virtual page offset for the kernel to kernel.Kmain
Ths page offset is defined in arch/XXX/constants.inc and needs to be
passed to the kernel so we can correctly calculate the physical frame
addresses that correspond to the ELF section virtual memory addresses.
2017-07-13 00:08:40 +01:00
Achilleas Anagnostopoulos
a2d58f8949 Switch to a visitor-based no-alloc implementation for fetching ELF sections
This change is required as the code to create a new PDT should execute
before the Go allocator is bootstrapped.
2017-07-13 00:08:40 +01:00
Achilleas Anagnostopoulos
fdd5611220 Fix bug in the ASM code used to load the PDT to the CR2 register
The previous implementation in Go assembly did not translate to the
correct assembly instructions for loading CR2
2017-07-13 00:08:40 +01:00
Achilleas Anagnostopoulos
9d2e53bac4 Redirect runtime.init to an empty stub 2017-07-13 00:08:35 +01:00
Achilleas Anagnostopoulos
a79be7c268 Support parsing of 64-bit ELF section tags off from the multiboot data 2017-07-10 19:08:28 +01:00
Achilleas Anagnostopoulos
af9613e336 Support extraction of boot cmdline off the multiboot data 2017-07-10 19:05:49 +01:00
Achilleas Anagnostopoulos
5ef344010b Support parsing of framebuffer color info out of the multiboot data 2017-07-10 19:05:01 +01:00
Achilleas Anagnostopoulos
8ac2ba82cc Implement function for mapping a contiguous physical memory region
The MapRegion function can be used by device drivers to ensure that they
can access memory mapped by the various devices.
2017-07-08 22:17:34 +01:00
Achilleas Anagnostopoulos
1b697fd125 Pass PrefixWriter with driver name and version to DriverInit calls 2017-07-08 22:09:19 +01:00
Achilleas Anagnostopoulos
da279cf3ff Implement PrefixWriter
PrefixWriter is a passthrough io.Writer that prepends a prefix to the
beginning of each line.
2017-07-08 22:09:13 +01:00
Achilleas Anagnostopoulos
ffb8f86a9c Each driver should manually register a probe function for use by hal
This commit removes the HWProbes() function from the console and tty
packages and replaces it with a global ProbeFuncs slice which is fetched
by the hal package when the hardware autodetection code runs.

Each driver should provide an init() function that appends a probe function
to the global ProbeFuncs slice.

This approach allows us to support conditional compilation of drivers in
the future (e.g. using build tags)
2017-07-08 12:26:40 +01:00
Achilleas Anagnostopoulos
562fae2028 Detect hw and wire active console and TTY 2017-07-07 21:37:00 +01:00
Achilleas Anagnostopoulos
eca1f6c26e Change early.Printf calls to kfmt.Printf 2017-07-07 21:37:00 +01:00
Achilleas Anagnostopoulos
545a18fccc Support pluggable output sinks for Printf with a ring-buffer fallback
The implementation of Printf has been moved from the early package to
the kfmt package. The dependency to ActiveTerminal has been removed and
the code now uses an io.Writer for its output. As Go interfaces cannot
be used before bootstrapping the Go runtime, the code uses a ring-buffer
fallback for storing any kernel output emitted before that point.
2017-07-07 21:37:00 +01:00
Achilleas Anagnostopoulos
f691d75b29 Implement ring-buffer for capturing early printf output
The ring-buffer implements both io.Reader and io.Writer and uses a fixed
size of 2048 bytes (set by the ringBufferSize constant). This provides
enough space to hold a standard 80x25 screen's output.
2017-07-07 21:37:00 +01:00
Achilleas Anagnostopoulos
0f3af2e78d Refactor VT implementation
This commit refactors the old VT implementation to work with the revised
TTY interface and adds support for:
- scrollback
- terminal state handling

When a terminal becomes activated, it overwrites the attached console
contents with the contents of its viewport.
2017-07-07 21:37:00 +01:00
Achilleas Anagnostopoulos
78c87ab165 Cleanup and revise TTY interface 2017-07-07 21:37:00 +01:00
Achilleas Anagnostopoulos
286b8d9c71 Rename Ega console to VgaTextConsole and implement the updated interface 2017-07-07 21:36:50 +01:00
Achilleas Anagnostopoulos
b72725742a Revise console interface 2017-07-07 06:25:24 +01:00
Achilleas Anagnostopoulos
d8793bd530 Move kernel panic implementation to the kfmt package 2017-07-07 06:25:24 +01:00
Achilleas Anagnostopoulos
dc37e86421 Run the init() function for all kernel packages and their dependencies
Things like error messages (e.g in the io pkg) are actually allocated
when init() is executed. Unless we trigger a call to init(), values like
this will be nil causing various problems when we try to use functions
from the stdlib.
2017-07-07 06:25:24 +01:00
Achilleas Anagnostopoulos
0bbaa1dbff Use correct FP offset for fetching the values passed to cpu.PortWriteXXX 2017-07-05 17:09:19 +01:00
Achilleas Anagnostopoulos
40521f8626 Ensure that the memory returned by sysAlloc is always zeroed 2017-07-05 16:50:59 +01:00
Achilleas Anagnostopoulos
4f3312b85d Implement functions for reading/writing from/to IO ports 2017-07-02 19:21:09 +01:00
Achilleas Anagnostopoulos
e4879b9f8a Support the CPUID instruction 2017-07-02 19:21:04 +01:00
Achilleas Anagnostopoulos
8dfc5d4e92 Use pwd as a workspace; move sources to src/gopheros and rewrite imports
By setting up pwd as a Go workspace, we can trim import paths from
something like "github.com/achilleasa/gopher-os/kernel" to just
"kernel".

These changes make forking easier and also allows us to move the code to
a different git hosting provider without having to rewrite the imports.
2017-07-01 20:37:09 +01:00