Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Arch independence #183

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

roblabla
Copy link
Member

For future AArch64 compatibility

@todo
Copy link

todo bot commented Jan 29, 2019

Find better work around cargo build not accepting empty arguments

https://github.com/roblabla42/KFS/blob/b8c7c3a48378ff2635044905df89e62677510a65/Makefile.toml#L10-L18


This comment was generated by todo based on a TODO comment in b8c7c3a in #183. cc @roblabla.

dependencies = ["kernel-linker", "install-rust-src"]
command = "cargo"
args = ["xbuild", "--target=i386-unknown-none", "--package=kfs-kernel", "--release" ]
args = ["xbuild", "--target=${TARGET}", "--package=kfs-kernel", "-Z", "package-features", "--features=panic-on-exception", "${RELEASE_FLAG}"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

panic-on-exception is a debug feature, it shouldn't be enabled when building for release ...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I guess I'll add a KERNEL_FLAGS env variable.

- Instead of duplicating rules for debug and release, we instead use profiles
  to determine whether we should build in Debug or Relase mode. We do this by
  adding two global env variables (TARGET_PATH and RELEASE_FLAG).
  TARGET_PATH should contain the PATH relative to target/ where we can find the
  compiled binaries.
  RELEASE_FLAG should contain --release in release mode, and a noop flag under
  debug mode. We use --message-format=human as a noop flag.

- We also support building for different targets using the TARGET environment
  variable, which defaults to i386-unknown-none.
Start refactoring the i386 module into an architecture abstraction module. The
arch module should export functions abstracting common operations across
multiple architectures, and expose a module containing the architecture-specific
functionality.

For now, the architecture abstraction API contains two functions:

- enable_interrupts, which allow hardware to call event::dispatch_event
- disable_interrupts, which tells hardware to queue interruptions.
The stub arch is a noop architecture where all the functions do nothing.
It's mostly meant to be used as a centralized place for the
documentation of the arch abstraction API, but can also be used for
tests and easily bootstrapping a port to a new architecture.
Adds two new functions to the arch abstraction API: get_cmdline and
get_logger. Those are used by the log implementation to find the serial
device to log to, and the log configuration.
The syscall module is moved to the root, making documentation better
(syscalls is right on kfs_kernel project page). Fixes sunriseos#54.

The rest of the interrupts module is fully arch-specific, so it is moved
under arch::i386.
start and common_start are both architecture-specific, so move them
under arch::i386.

Furthermore, init the multiboot2 global as early as possible, and make
frame_allocator take the multiboot2 information with
`get_boot_information` function.
Adds a new function: force_logger_unlock, which force-unlocks any Mutex that
might be protecting the logger. This is only used in the panic implementation,
in order to avoid deadlocking.

Panic now uses get_logger in order to stay arch-generic.
Adds two new function and one structure to the arch abstraction API:

- ThreadHardwareContext, contains some support fields for the process
  switching code.

- process_switch: Executes another process.

- prepare_for_first_schedule: Prepare a new thread to get scheduled/switched to.
Adds a new trait: `elf_loader::Module`, representing a kernel builtin
that will be loaded when booting the kernel.

Adds a new function to arch abstraction API: get_modules(). This
function returns an iterator of `Module`s. All of those modules are to
be started on kernel boot.
Adds a new type in arch-generic API, KernelStack, and a new function,
dump_stack. KernelStack represents the Kernel Stack used to handle
interruptions associated with a ThreadStruct.

Having KernelStack in the arch-generic API is a bit weird. The concept
is inherently arch-dependent...
A few simple improvements to set_bits_area:

- It is now available to both BitField and BitArray
- It now uses RangeBounds, allowing the use of inclusive ranges, partial
  ranges, and full ranges.
- It now has tests.
for_each_region is similar to for_each_entry, but runs for each
contiguous region in the same "state". It is effectively the logic used
by dump_kernelland_state, ripped in a generic function.
Make the frame allocator atomic. This allows allocating frames from
multiple CPU cores without having to go through a global lock.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants