Commit Graph

121 Commits

Author SHA1 Message Date
Martin Whitaker
efc9a9c16a Don't attempt to start the APs when restarting after a config change.
Leave the APs running whilst the BSP repeats the dummy runs. This means
we need to bypass the barriers during a dummy run. The APs will wait at
the first barrier until the BSP starts the first real run.
2022-02-12 19:37:58 +00:00
Martin Whitaker
c23b129e55 Remove delay loop from spinlock wait.
Now we halt CPU cores that are going to be idle for a lengthy period,
we don't need to try to save power in other ways. And anyway, this was
not very effective.
2022-02-12 19:33:53 +00:00
Martin Whitaker
2bf1623733 Halt CPU cores that are not active in a test.
This saves a lot of power when performing sequential tests.
2022-02-12 19:30:14 +00:00
Martin Whitaker
de32bc5412 Ensure we only use 32-bit reads and writes when accessing APIC registers. 2022-02-12 09:39:18 +00:00
Martin Whitaker
99e258457b Use je/jne instead of jz/jnz when testing boolean variables in startup code.
Just for readability - they are aliases for the same instructions.
2022-02-12 09:39:18 +00:00
Martin Whitaker
39d5715224 Fix interrupt handling when long mode is enabled in a 32-bit binary (part 2).
Handle passing the processor state to the application interrupt handler.
Update the 64-bit code to match the new trap state structure definition.
2022-02-12 09:39:09 +00:00
Martin Whitaker
111e619b10 Fix interrupt handling when long mode is enabled in a 32-bit binary (part 1).
If long mode is enabled, the interrupt handler always runs in 64-bit
mode, so we need to set up the interrupt dispatch table accordingly.
2022-02-08 23:35:00 +00:00
Martin Whitaker
e96fd7b99f Fix a few minor issues in the 64-bit startup code...
- the calculation of the RSP value when an interrupt occurred was
  out by 8 bytes
- in a few places a 32-bit pointer was used instead of a 64-bit one
- incorrect tabulation (white space)
2022-02-08 23:29:24 +00:00
Martin Whitaker
93343db711 Remove redundant barrier. 2022-02-07 18:50:22 +00:00
Martin Whitaker
3028cd31f9 Increase sleep time when polling for all other APs started.
Also fix warning about usleep not being defined.
2022-02-05 18:07:03 +00:00
Martin Whitaker
242bd77927 Remove unwanted debug code. 2022-02-05 18:04:38 +00:00
Martin Whitaker
7dd17c26c0 Check whether the BIOS has enabled x2APIC mode, and disable SMP if so. 2022-02-05 18:03:32 +00:00
Martin Whitaker
29b8bbece8 Rework AP startup based on how it's done in Linux. 2022-02-05 18:03:32 +00:00
Martin Whitaker
503aea321d Remove redundant start_mutex.
The mutex is now implemented in the assembly language boot code.
2022-02-05 18:03:32 +00:00
Martin Whitaker
9769990679 Extend the use of the startup mutex to cover the entire startup code.
There is more in the startup code that isn't thread safe than just
the use of the temporary stack. So take the mutex for the whole time.
The code isn't that long, so it's not worth trying to cover just the
critical sections.
2022-02-05 18:03:32 +00:00
Martin Whitaker
13efd906f1 Guard against an AP starting more than once. 2022-02-03 19:48:27 +00:00
Martin Whitaker
e37fbbd429 Set stack alignment to 16 bytes.
This needs to be done in the ldscripts.
2022-02-02 18:23:23 +00:00
Martin Whitaker
1888f5c611 Add change to tests/test.c missed in commit dcac5270. 2022-02-02 15:33:25 +00:00
Martin Whitaker
7acb81e302 Fix assembler warning about unsized bts instruction. 2022-02-02 12:52:44 +00:00
Martin Whitaker
dcac527068 Don't make assumptions about usable memory.
When using a legacy BIOS, the memory regions used by the BIOS are well
defined. This is not the case when using a UEFI BIOS. So include the
stack area in the BSS so the loader knows how much memory to allocate,
and check we have space to relocate the program to either low or high
memory.

There are still some assumptions in the USB driver code that need to
be fixed.
2022-02-02 12:20:39 +00:00
Martin Whitaker
fb0f1a7fe5 Don't start APs until after dummy runs have finished.
This should significantly improve startup time on machines with many
cores, as the barriers become no-ops during the dummy runs.
2022-02-01 23:50:49 +00:00
Martin Whitaker
fd141c59c7 Use "CPU core" in preference to "CPU" in comments. 2022-02-01 15:42:44 +00:00
Martin Whitaker
da0d2a9fc3 The apic_id_to_cpu_num[] map needs to be unsigned to support > 256 cores. 2022-02-01 15:40:52 +00:00
Martin Whitaker
ccab9ab081 Fix operation with a subset of CPU cores enabled.
The last commit removed too much - there are a couple of places where
we need to use a virtual CPU number rather than a physical CPU number.
2022-02-01 15:38:06 +00:00
Martin Whitaker
16d55b7dad Remove distinction between physical and virtual CPUs.
This is no longer needed, now we can display as many CPUs as we can
physically handle.
2022-01-31 22:59:14 +00:00
Martin Whitaker
4100a44b12 Properly protect the startup stack with a mutex.
Because we start the APs sequentially, it is unlikely they will coincide
for the brief period that they use the temporary startup stack, but we
should guard against it. This allows us to remove the mutex around the
restart of each AP when relocating, which should improve test times.
2022-01-31 21:54:24 +00:00
Martin Whitaker
17093a96f9 Optimise the AP startup code to reduce the startup delay. 2022-01-31 19:47:32 +00:00
Martin Whitaker
7c3e7d536c Allow cursor keys to be used in CPU mode and error mode config menus. 2022-01-30 15:47:17 +00:00
Martin Whitaker
e13b8bbb83 Increase config pop-up window width.
Also add more constant definitions to better parameterise the layout.
2022-01-30 15:37:13 +00:00
Martin Whitaker
f348add314 Remap numeric keypad to cursor keys. 2022-01-30 15:18:25 +00:00
Martin Whitaker
4589c7dad4 Recognise cursor keys and map them to 'l', 'r', 'u', 'd'. 2022-01-30 15:12:42 +00:00
Martin Whitaker
151870cc0b Display enabled CPUs as a scrollable list in the config menu.
This removes a constraint on the number of CPU cores we can support.
2022-01-30 15:12:04 +00:00
Martin Whitaker
ab278566e4 Bypass start barriers during dummy runs.
This should speed up the dummy runs on distributed SMP systems.
2022-01-29 17:11:46 +00:00
Martin Whitaker
c5e9fa4e18 Increase maximum number of APs to 256. 2022-01-29 16:13:05 +00:00
Martin Whitaker
ed02a3baef Support display of more than 32 CPU cores in the config menu. 2022-01-29 16:00:33 +00:00
Martin Whitaker
fe4374e818 Allocate the main program stacks after the loaded program.
After we relocate the program, we restart it. So there is no need to copy
over the old stack contents. This allows us to increase the maximum number
of APs without a run time overhead. The maximum number of APs will still
be limited by the size of low memory.
2022-01-29 15:17:00 +00:00
Martin Whitaker
73bfc1878a Blank the full field when displaying the active CPU core. 2022-01-29 15:06:21 +00:00
Martin Whitaker
f04cb1adb6 Make spinner rotate at a constant speed. 2022-01-29 15:06:21 +00:00
Martin Whitaker
3c69cd07b7 Guard against missing TSC and divide by zero in elapsed time calculations. 2022-01-29 15:06:21 +00:00
Martin Whitaker
09890bf0cd Support more than 32 CPU cores in main display.
Either one core is active or all enabled cores are active, so we don't
really need a separate spinner for each core.
2022-01-29 15:06:05 +00:00
Martin Whitaker
4791206bbd Use consistent CPU sequencing mode abbreviations in config menu. 2022-01-28 21:57:39 +00:00
Martin Whitaker
01365ab2e7 A few more code tweaks and comment typo fixes in the EHCI driver. 2022-01-28 19:55:31 +00:00
Martin Whitaker
8509e3320a Minor code tweaks - no functional change. 2022-01-23 17:55:57 +00:00
Martin Whitaker
563c8a1ee7 Add support for EHCI USB controller. 2022-01-23 17:38:50 +00:00
Martin Whitaker
5b56d76e03 Minor fixes and refactoring in preparation for EHCI support. 2022-01-23 17:34:08 +00:00
Martin Whitaker
79ec174a82 Update known limitations in README, now USB hubs are supported. 2022-01-09 21:45:07 +00:00
Martin Whitaker
0fded3e321 Store pmem temporary arrays on the stack to reduce memory footprint.
Now we have more stack space available for the BSP during initialisation,
we no longer need to store the temporary data off stack.
2022-01-09 21:27:44 +00:00
Martin Whitaker
0aa1b1fa97 Rearrange stack space to reduce memory footprint.
The BSP only needs extra stack space during program initialisation. The APs
aren't running at that point, so by positioning the BSP stack above the AP
stacks, it can extend down into the AP stack space without causing any
problems.
2022-01-09 21:25:16 +00:00
Martin Whitaker
a454174f3f Fis startup stack address calculations. 2022-01-09 19:26:56 +00:00
Martin Whitaker
4400ec6f17 Rename usbkbd to usbhcd to better reflect the new design. 2022-01-08 23:14:50 +00:00