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

262 Commits

Author SHA1 Message Date
Achilleas Anagnostopoulos
86609fea06 Merge pull request #40 from achilleasa/map-vga-text-fb
Map vga text console framebuffer
2017-07-08 22:25:49 +01:00
Achilleas Anagnostopoulos
13ef4cd08d Map physical address of the vga text console framebuffer in DriverInit
Currently, the kernel can write to 0xb80000 because this is part of the
initial identify mapping set up by the rt0 code. When we establish new
mappings for the kernel using its real VMA address then writes to the
framebuffer will cause a page fault unless we explicitly map it.
2017-07-08 22:18:24 +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
42e6802323 Merge pull request #39 from achilleasa/enhance-hal-output-log
Enhance hal output log
2017-07-08 22:15:06 +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
3485523cdc Update the Driver.DriverInit method signature to accept an io.Writer
Drivers can use the writer as an argument to kfmt.Fprintf to log
additional output during their initialization.
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
b1084c1362 Fix broken unit tests 2017-07-08 13:02:15 +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
4845f7a4ca Use uint32 instead of uint16 for TTY coordinates 2017-07-08 12:26:40 +01:00
Achilleas Anagnostopoulos
fd3ca91138 Use uint32 for console coordinates and fix dimension bug 2017-07-08 12:26:40 +01:00
Achilleas Anagnostopoulos
d804b17ed8 Merge pull request #38 from achilleasa/refactor-console-and-tty-drivers
Refactor console and tty drivers
2017-07-07 21:44:15 +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
425ad7319b Define driver interface
This interface must be implemented by all device drivers in the driver
sub-packages.
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
a1d65d4c09 Setup fs register according to the ELF TLS handling manual for x86-64
According to the ELF runtime handling of TLS document, the x86-64 arch
uses the same TLS handling variant (GNU) as the IA-32 ABI with the
exception that pointers are 8-byte wide and that the gs register is
swapped with fs. fs:0x0 points to the TCB; TLS variables are located
before it and are accessed using negative offsets from the TCB pointer.
In the Go case the G struct is accessed at fs:-0x8.

For more detauls see: https://www.akkadia.org/drepper/tls.pdf
2017-07-07 06:25:04 +01:00
Achilleas Anagnostopoulos
7cef79ca12 Update .gitignore 2017-07-06 06:13:13 +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
dd63b23246 Merge pull request #37 from achilleasa/support-cpuid-and-implement-port-rw-helpers
Support CPUID and implement port R/W asm helpers
2017-07-02 19:27:30 +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
e580dea9d1 Merge pull request #36 from achilleasa/use-project-specific-go-workspace
Use project-specific go workspace and rewrite import paths
2017-07-02 06:58:36 +01:00
Achilleas Anagnostopoulos
5f8f42a0c5 Override GOPATH when collecting coverage 2017-07-02 06:39:19 +01:00
Achilleas Anagnostopoulos
f961270904 Use the new Go workspace paths when building qualified symbol names 2017-07-02 06:39:19 +01:00
Achilleas Anagnostopoulos
00fdf79888 Append pwd to GOPATH when compiling the kernel
The Makefile changes create a standalone Go workspace routed at pwd
2017-07-02 06:39:13 +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
Achilleas Anagnostopoulos
7b93d01c6e Merge pull request #35 from achilleasa/bootstrap-interfaces-and-map-primitive
Enable support for interfaces and the map primitive
2017-06-30 18:35:10 +01:00
Achilleas Anagnostopoulos
cd7e7ed15a Enable support for interfaces and the map primitive 2017-06-30 18:17:03 +01:00
Achilleas Anagnostopoulos
264ea09b9a Merge pull request #33 from achilleasa/bootstrap-go-allocator
Bootstrap Go allocator
2017-06-30 09:30:44 +01:00
Achilleas Anagnostopoulos
effc6710d9 Initialize Go memory allocator 2017-06-30 09:21:05 +01:00
Achilleas Anagnostopoulos
b4f4a9a738 Provide replacement for runtime.sysAlloc 2017-06-30 09:21:05 +01:00
Achilleas Anagnostopoulos
636220ab1d Unexport bitmap allocator instance and export AllocFrame helper
This allows us to mock calls to the frame allocator from other packages
while testing.
2017-06-30 09:21:05 +01:00
Achilleas Anagnostopoulos
6ee95b439e Provide replacement for runtime.sysReserve 2017-06-30 09:21:05 +01:00
Achilleas Anagnostopoulos
5e5e9f1c0b Redirect runtime.throw to kernel.Panic via kernel.panicString 2017-06-30 09:21:05 +01:00
Achilleas Anagnostopoulos
ce34763e23 Redirects tool should only consider comments attached to functions 2017-06-30 09:21:05 +01:00
Achilleas Anagnostopoulos
336cbb415d Fix lint warning 2017-06-30 09:20:24 +01:00
Achilleas Anagnostopoulos
df6e4314ca Merge pull request #34 from achilleasa/remove-hardcoded-g-offsets-from-rt0-code
Remove hardcoded g offsets from rt0 code and use runtime.g0/m0
2017-06-30 09:18:17 +01:00
Achilleas Anagnostopoulos
b733915536 Use runtime.g0, runtime.m0 and replace hardcoded offsets
The rt0 code implements a dedicated function for initializing the Go runtime
structures. Instead of reserving space for a dummy g struct, the rt0
code now uses the g0 and m0 symbols defined by the runtime package. In
addition to setting up g0, the rt0 also sets up the m0 struct and links
it to g0.

Setting up m0 is a requirement for properly bootstapping the
malloc-related code in the following commits
2017-06-30 09:08:32 +01:00
Achilleas Anagnostopoulos
6820ffef2b Generate offset definitions as part of the build process
The Makefile contains rules for invoking the offsets tool to generate
the offset definitions for members of the g, m and stack structs. The
definitions are stored in BUILD_DIR and BUILD_DIR is passed as an
include target to nasm.
2017-06-30 09:01:41 +01:00
Achilleas Anagnostopoulos
62aca2f2de Implement tool for calculating offsets into g, m and stack structs
The offsets tool is essentially a wrapper around "go build -a -n". It
creates a temporary folder with a dummy go file and runs the above
command using the target OS/ARCH for the kernel and captures the output.
The use of the "-a" flag forces go build to generate a build script for
rebuilding all packages including the runtime ones. As a by-product of
building the runtime package, the compiler emits the "go_asm.h" file
that contains (among other things) the offsets for each element of the
g, m and stack structures (see src/runtime/runtime2.go).

These offsets are used in Go assembly files instead of hardcoded
offsets. For example the following snippet accesses the pointer to m in
the g struct address stored at register CX:

MOVQ TLS, CX
MOVQ g_m(CX), BX

The offsets tool modifies the captured output from the go build command
so it only includes the steps up to building the runtime package,
executes the build script and post-processes the generated go_asm.h file
to retain the entries relevant to g, m and stack and then formats them
so they are compatible with nasm definitions (name equ value).

Depending on the value of the "-out" option, the tool outputs the
generated definitions either to STDOUT (default value for -out) or to a
file.
2017-06-30 09:01:41 +01:00
Achilleas Anagnostopoulos
0c79af3f90 Substitute source paths when running GDB on OSX
The generated DWARF information contains absolute file paths for the
source files which causes issues when debugging on OSX as GDB cannot
lookup the source files.
2017-06-28 18:18:00 +01:00