Commit graph

14 commits

Author SHA1 Message Date
bunnie
d44ab2f2aa add the .a artifacts to the tree for the asm.S
these are just sync'd to the asm.S and checked in.

Eventually, we should migrate that .S file into using
in-line assembly macros, but now that I look at it, I remember
why it hasn't been done yet -- there are some fancy conditionals
used to enable compatibility with different architectures that
I don't know off the top of my head how to translate into
in-line assembly syntax.
2024-01-06 16:41:40 +08:00
Sean Cross
124040bbb3 kernel: asm: align kernel stack to 16 bytes
The kernel stack offset should be aligned to 16 bytes. Previously it was
aligned to 8 bytes. It's unclear if this was the cause of any issues,
but it is best practice to keep things aligned to 16 bytes.

As part of this, key the atomic instructions off of the CPP macro
presence of atomic instructions.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-29 18:15:48 +08:00
Sean Cross
dbf28fbd61 kernel: use correct fake interrupt cause
Previously, we were creating a fake interrupt that was a "user software
interrupt". Update this to be a "supervisor external interrupt" to fix
hardware resume.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-04-09 15:31:06 +08:00
eupn
90df83f885
kernel: revamp IRQ handling 2023-04-05 16:35:01 +04:00
eupn
89a1447df4
kernel: checkout arm assembly binary 2023-03-14 18:41:45 +04:00
Sean Cross
dc097e32d8 kernel: fix atomic operations
Atomic operations were previously broken. RISC-V breaks atomic
operations into multiple instructions, and there is some state kept
between those instructions. This state is not visible, and is internal
to the processor.

We were ignoring this state, which resulted in inconsistencies
throughout the system. The following sequence was possible:

1. A thread loads a value, and obtains the `reservation set`
2. A context switch happens on the following instruction
3. A different thread loads the value, modifies it, and continues
4. A third thread (or a different process) loads a value and obtains the
   `reservation set`
5. The original thread runs, sees the `reservation set` is held, and
   updates the value, clobbering what the second thread did in #3

A workaround for this is to perform a dummy `sc` as part of the context
switch. This invalidates any atomic operations that may be pending.

Signed-off-by: Sean Cross <sean@xobs.io>
2023-02-02 23:10:12 +08:00
Sean Cross
19653e9c53 kernel: compatibility with riscv32imac-unknown-xous-elf
Signed-off-by: Sean Cross <sean@xobs.io>
2021-08-18 18:14:24 +08:00
bunnie
260b154741 clean up some boot process holdovers 2021-04-30 23:28:31 +08:00
bunnie
640ddb48e8 suspend/resume now works to hardware 2021-04-30 19:29:36 +08:00
Sean Cross
21c46de60e kernel: move to allow hosted init
This prepares for new calls to init SystemServices and the MemoryManager
so that they can be initialized with something other than a
KernelArguments struct.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-06-03 18:28:22 +08:00
Sean Cross
dafec2bb89 kernel: make contexts first-class
Due to an initial misunderstanding of how the RISC-V is architected,
contexts were going to be an emergent property of the kernel.

However, after further consideration, contexts must now be baked into
the kernel.  Switching between contexts can be handled by the scheduler,
but the kernel must keep track of processor registers.

Keep track of context IDs and ensure they are sane.  With this patch,
interrupts work, as does basic context switching.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-27 12:30:29 +08:00
Sean Cross
fa22d9bad8 kernel: fix isr context handling
We were loading both the context and the banked context, which resulted
in an invalid context being selected.  This caused a cascading failure.

Load only the lower halfword in order to correctly enter the interrupt
context.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-24 15:24:19 +08:00
Sean Cross
022bedc8e3 kernel: refactor processes to support banking
We now have a concept of context banking.  When an interrupt fires, the
process context is banked.

As part of this, process-level data is now stored in the page within the
process itself.  This reduces memory consumption and allows us to have
features such as a hash within each process itself.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-16 18:22:59 +08:00
Sean Cross
f50ec67553 initial commit
This pulls together many disparate repositories into one xous-core
repository.

Signed-off-by: Sean Cross <sean@xobs.io>
2020-03-10 12:13:05 +08:00