Commit Graph

41 Commits

Author SHA1 Message Date
Travis Geiselbrecht
be52909f49 [make][buildall] add ability to filter buildall by architecture
Clean up make targets list-arch and list-toolchain to be much faster and
work without needing to invoke the archtecture's arch rules.mk. This
should make it work on machines that do not have that particular
toolchain in the path.

This is setting up for using it in the github action script.
2025-07-18 21:51:50 -07:00
Travis Geiselbrecht
699ec6344e [arch][x86][smp] few misc tweaks
- Skip cpus in the MADT table that are not enabled
- Bump count to 16 cpus
- Move the spurious interrupt vector to 0xff since it needs to end in
  0xf on <=P6.
2025-04-06 22:22:20 -07:00
Travis Geiselbrecht
8fdadd9b33 [arch][x86] implement basic spinlocks
-This fixes the instability, seems stable on x86-64.
2025-04-01 20:10:18 -07:00
Travis Geiselbrecht
5a520eca3e [arch][x86] start getting inter-processor-interrupts working
-Move the local apic driver to arch/x86
-Add routines to send IPIs between cpus

Something is unstable at the moment and the system crashes after a while
with random corruptions when using SMP.
2025-04-01 00:40:50 -07:00
Travis Geiselbrecht
3ea007a237 [arch][x86] split the single GDT.S into two separate ones per subarch
It's getting too hard to maintain a single layout that works with both,
so go ahead and split it. Also redo the layout so it should be usable
with user space and syscall and sysenter instructions from either mode.
2024-12-12 22:23:50 -08:00
Travis Geiselbrecht
6538baea70 WIP x86-smp
add uspace mmu support for x86-64
trampoline x86-64 cpus to long mode and into the kernel aspace
2024-12-11 00:19:57 -08:00
Travis Geiselbrecht
181796e843 WIP x86 get x86-32 working with a per-cpu gs: segment register for the kernel 2024-12-06 22:30:48 -08:00
Travis Geiselbrecht
902e2fcb8a WIP set up per cpu structures for x86-64
only on the boot cpu for now
2024-12-06 21:11:51 -08:00
Travis Geiselbrecht
fd79fccdde WIP x86 SMP 2024-12-06 00:03:48 -08:00
Travis Geiselbrecht
7742bd021b [arch][x86] general cleanup
Clean up the x86.h file a bit with how constants are defined
Switch rdtsc to builtin
Added all of the known bits for the main CR registers.
Move the invlpg macro over to the common header.
Update comments in start.S
2022-11-02 23:02:24 -07:00
Travis Geiselbrecht
8643334914 [platform][pc] update the multiboot memory detection code
Parse up to 16 pmm arenas from the multiboot memory data structure. Roll
the 32bit code to properly trim at 1GB as before, but using new logic.
Remove conditional checks on WITH_KERNEL_VM in x86 code, which only
really compiles with the mmu and the vm on.
2022-08-07 16:28:03 -07:00
Travis Geiselbrecht
fb373eb4de [arch][x86] drop march to x86-64
-march=x86-64-v2 is not supported on old compilers.

Can fix in the future, but for the moment may as well just drop -v2
since it's not really being used.
2022-07-24 20:03:46 -07:00
Travis Geiselbrecht
7505c3087a [arch][x86][fpu] spiff up the fpu code to detect things more cleanly
Doesn't really change the functionality of the code except it'll try to
work with less fpu features present.
2022-07-24 19:56:24 -07:00
Travis Geiselbrecht
c429ffcc7a [arch][x86] add more comprehensive feature bit routine
Cache copies of the first few cpuid leaves from each bank at bootup if
present. Add a fast routine to test feature bits out of this array.
2022-07-24 16:59:45 -07:00
Travis Geiselbrecht
6462cbf51c [arch][fpu] add ability to specify per file or module if code needs fpu
Have the arch define additional compiler flags to explicit support or
not support a floating point unit.

Add ability for modules to per file or for the whole module mark code
as needing floating point support.

Add default flags for arm64, riscv, and x86 toolchains.

Needed because gcc 12 is getting much more aggressive about using vector
instructions for non float code, so getting away with avoiding it was
no longer working.

Still not perfect: printf code is being compiled with float, so it's
possible to use floating point instructions inside core kernel or
interrupt handling code if a printf is used.

Possibly will have problems on architectures where mixing float and non
float code at the linker generates issues, but so far seems to be okay.
2022-07-17 16:32:24 -07:00
Travis Geiselbrecht
18330c5948 [arch][x86] start of cpu detection and feature detection 2022-01-09 18:20:14 -08:00
Travis Geiselbrecht
7102838b49 [arch] have each arch define ARCH_HAS_MMU
This lets some code decide whether or not there's any mmu
present to use. Also kernel VM will complain if it isn't set
as an extra safety.
2021-03-30 02:48:59 -07:00
Travis Geiselbrecht
f8effeba66 [arch][x86] switch x86 to the builtin atomics
Easy to do except for the legacy compile case for i386, in which case we
have to start defining fallthrough atomic routines that the compiler
will call.

At the moment only implement __atomic_fetch_add_4 since its the only one
in use.
2020-05-16 14:29:21 -07:00
Travis Geiselbrecht
d0f1944038 [arch] define the atomic routines in arch-neutral headers and use builtins
Generally move most arches over to using the builtin atomics except for
the few that still require a little bit of work.
2020-05-16 14:29:21 -07:00
Travis Geiselbrecht
5969063a52 [arch][x86][64] Get the 64bit build working again
Set -fno-builtin to keep the compiler from generating load/stores using
sse outside of floating point code. Not ideal for a lot of reasons but
it's difficult to segregate kernel code and user code such that it only
generates SSE instructions there.

Will probably need to do some work to let certain flags be set per
module, and then have only some of the modules be marked as user vs
kernel.
2020-03-07 18:06:01 -08:00
Travis Geiselbrecht
1fbb67228d [platform][pc] get working on legacy 386 PC
-Add support for x86 legacy mode, designed for 386+ instead of pentium+
-Fixup uart driver to support com2
-Stub out PCI driver properly
-Fixup IDE driver to detect legacy disks
2018-12-30 21:08:58 -08:00
Travis Geiselbrecht
5d43aa25eb [arch][rules] create ARCH_LDFLAGS and clean up all the arch rules files to consistently use ARCH_* vars 2018-11-30 22:00:45 -08:00
Travis Geiselbrecht
ee672a5471 [arch][x86] flatten x86-64 and x86 into a single tree of code
Major refactor of x86 code into a single arch.
Also bump both 32 and 64 bit to running the kernel at a 'high' address.
2016-02-29 12:42:45 -08:00
Zhu, Bing
b6647f5bef [arch][x86][fpu]Change naming convention for FPU flag
To align with lk/arm flag naming convention, FPU flag
ENABLE_FPU is changed to X86_WITH_FPU

Signed-off-by: Zhu, Bing <bing.zhu@intel.com>
2015-11-09 22:14:11 +08:00
Travis Geiselbrecht
2c52edce0b [app][tests] set ENABLE_FPU in arch/x86 targets, enable floating point tests 2015-10-27 13:19:07 -07:00
yu-cheng yu
0400a04945 [arch][x86] This is floating point support for intel x86 and x86-64.
Change-Id: Id0b0e2b69c1d27832eb656935e944c04681b324a
2015-10-27 13:04:45 -07:00
Travis Geiselbrecht
3b2d7a268b [make] remove the need for a module to manually add $(LOCAL_DIR)/include to the global include path
Pretty much every module in the system was already doing it, so do it
automatically.
2015-10-19 19:07:16 -07:00
Travis Geiselbrecht
713e138de9 [arch][x86] clean up the way memory size is detected and the vm initialized
Also fix a few warnings in arch/x86
2015-10-11 14:09:55 -07:00
Shreyas Nagaraj
57a08b7f65 [arch] [x86] - changes to MMU for x86, x86-64 and x86-PAE
fixing bugs in page table mgmt and overall MMU code clean-up

Signed-off by: Shreyas Nagaraj <shreyas.nagaraj@intel.com>
2015-07-01 00:36:12 -04:00
Sergio Rodriguez
7a36b2d59d rebasing x86 paging support to master 2015-06-11 13:54:00 -07:00
Sergio Rodriguez
8b78376b6b adding paging support for x86 2015-06-11 12:05:12 -07:00
Travis Geiselbrecht
45d56cc2e1 [arch][x86] get x86 building and working again after SMP changes
-Add UP spinlock routines and irq save/restore
-fix platform/pc drivers to use spinlocks instead of critical_section
2015-03-10 16:43:55 -07:00
Travis Geiselbrecht
5ec27b2b01 [arch][x86] change the logic for figuring out the default TOOLCHAIN_PREFIX
Recent changes to makefile caused TOOLCHAIN_PREFIX to always be set to
something, so change the behavior here to match what arm does.
2014-08-10 20:04:38 -07:00
Travis Geiselbrecht
f21ad5d749 [make] miscellaneous make system tweaks
-Have arch set the default optimization level. Most will use
 O2, but arm-m sets to Os.
-Make the link time garbage collection be optional. Only set
 for arm-m.
2014-03-22 21:03:03 -07:00
Travis Geiselbrecht
28bc7f4b6d [arch] factor some common parts of linker scripts into a separate file
INCLUDE the parts of the linker script that are specific to lk into
each of the arch's scripts.
2013-06-20 21:03:56 -07:00
Travis Geiselbrecht
e002c58b59 [make] rename INCLUDES -> GLOBAL_INCLUDES
To be more consistent, rename make variable INCLUDES to GLOBAL_INCLUDES.
Also remove the need to put -I in front of each field, the make system
will do that for you.

To fix your module makefiles:
-Change INCLUDES -> GLOBAL_INCLUDES
-Remove -I prefix
2013-06-07 22:26:06 -07:00
Corey Tabaka
0c7109b838 [arch][x86] Fix arch to use new module conventions. 2012-10-05 23:51:28 -07:00
Travis Geiselbrecht
97cfd0bfa4 [make] update all of the rules.mk to use the new module system 2012-08-31 15:52:24 -07:00
Travis Geiselbrecht
4b7fd32e65 [make] remove the BOOTOBJS variable, ordering is handled via a special linker section 2012-01-24 15:42:44 -08:00
Corey Tabaka
6a5b7a0420 Added check for compiler support of -fno-stack-protector and changed toolchain prefix to i386-elf- for x86 port. 2009-04-24 11:14:38 -07:00
Corey Tabaka
d4427fa54c Initial x86 port 2009-04-24 11:14:38 -07:00