Commit Graph

149 Commits

Author SHA1 Message Date
Martin Whitaker
9f92ecf761 Fix the remapping of the screen frame buffer.
The size of the region to be mapped is determined by the buffer stride,
not the pixel width.
2022-04-11 21:46:49 +01:00
Martin Whitaker
84a54ca083 uhci: use multiple TDs for data transfers larger than the max packet size.
Unlike the other USB controllers, a UHCI transfer descriptor can only
request a single packet.
2022-04-11 21:17:09 +01:00
Martin Whitaker
ae2c010610 uhci: fix device speed setting when constructing a transfer descriptor. 2022-04-10 11:53:01 +01:00
Martin Whitaker
4c55182cd0 Disable UHCI legacy support and make sure all UHCI registers are initialised.
The controller reset should set the USBINTR, FRNUM, and SOF registers to
their default values, but set them explicitly just to be sure.
2022-04-09 22:42:59 +01:00
Martin Whitaker
4761b782dd Enable detection of keyboards attached to a UHCI controller. 2022-04-07 18:05:45 +01:00
Martin Whitaker
08bbac1065 uhci: reset the queue head after handling a keyboard interrupt.
When an interrupt transfer completes, the UHCI loads the QELP in the
QH with the link pointer from the TD (which is a null pointer in this
case). We need to set the QELP back to point at the TD to enable the
next interrupt transfer.
2022-04-07 17:51:27 +01:00
Martin Whitaker
75bc6822f8 uhci: set the link pointer terminate bit in the last TD in a queue. 2022-04-07 17:43:39 +01:00
Martin Whitaker
6cfb7e7e83 Miscellaneous fixes to the UHCI driver.
This gets us to the point that a keyboard is detected when running
QEMU with a EHCI/UHCI combination controller and the first keypress
is detected and returned.
2022-04-07 00:31:59 +02:00
Sam Demeulemeester
43302bf193 Add SPD decoding for DDR memory modules 2022-04-06 23:55:38 +02:00
Martin Whitaker
2c33aa3e85 Check for correct address space in probe_usb_controller() (issue #36).
We expect UHCI controllers to be mapped into I/O space and the other
controller types to be mapped into Memory space. Print a diagnostic
message and abort if this is not the case. Only call map_region()
for controllers mapped into Memory space.
2022-04-06 20:46:08 +01:00
Martin Whitaker
711596edbb Add boot command line option to ignore any EHCI controllers. 2022-04-04 22:53:39 +01:00
Sam Demeulemeester
2e048a7c61
Add support for Serial/TTY (#32)
* Add preliminary support for TTY Serial/UART (#15)

* Use shadow_buffer instead of VGA buffer to get a framebuffer-agnostic TTY supprot

* Added menu browsing & inputs from Serial TTY (#15)

* Add fix for degree symbol on TTY. Correct serial.c & serial.h file created with CRLF (#15)

* Move tty_error_redraw() to insure correct redraw when a error occurs

* Many reindent / cleanup

* Various optimization from @martinwhitaker comments
2022-04-04 18:31:54 +02:00
Lionel Debroux
5cc72a6bed
Fix up the SMBIOS parser so that it doesn't perform all kinds of OOB accesses when dealing with invalid input. (#26) 2022-04-02 15:43:46 +02:00
Martin Whitaker
95c49848c8 Use the PRC status bit to detect when an XHCI port reset is complete (issue #31).
Some controllers do not set the PR status bit immediately after it's written,
so polling that to detect when the reset is complete is unsafe.
2022-04-02 09:28:34 +01:00
Martin Whitaker
bbfaf10240 Revert "Correct the minimum recovery time needed to reset the XHCI port (#31)"
This reverts commit a95c554c6b.
2022-04-02 09:21:30 +01:00
Sam Demeulemeester
a95c554c6b Correct the minimum recovery time needed to reset the XHCI port (#31) 2022-04-01 22:06:01 +02:00
Sam Demeulemeester
ee80684c4f Separate benchmark from smbus/smbios and add a separate flag to enable/disable it 2022-04-01 20:34:52 +02:00
Sam Demeulemeester
4a20637f8e Add support for AMD Cezanne APU (Ryzen 5000G) #21 2022-04-01 18:55:43 +02:00
Sam Demeulemeester
d356a7e3f0 Parse MADT table header with the correct struct (#29) 2022-04-01 13:46:04 +02:00
Martin Whitaker
c13bb30893 Fix mapping of MADT (issue #29)
We need to pass the physical address of the MADT to parse_madt(), not the
virtual address of the table signature, because parse_madt() needs to call
map_region() again to ensure the full table is mapped into virtual memory.
2022-04-01 10:22:25 +01:00
Lionel Debroux
e0d42db07c Optimize the code by declaring several functions static in system/ehci.c.
`size memtest_shared` indicates that this saves 200- (x86) / 200+ (x86_64) bytes, but alignment hides the gain.
2022-03-30 11:54:56 +02:00
Sam Demeulemeester
b6e2a2ace8 Attempt to fix another issue related to #19 by adding a BENCH_MIN_START_ADR constant to force bench location > 16MB in all cases. Correct mem_test_len by adding a x2 multiplier (len=src+dst) 2022-03-29 00:42:34 +02:00
Sam Demeulemeester
a4f1ba37b3 Add support for AMD Ryzen FCH (#21) 2022-03-27 23:47:57 +02:00
Sam Demeulemeester
f7ae4dd395 Add support for Zhaoxin ZX-E & KX CPUs 2022-03-25 20:14:16 +01:00
Sam Demeulemeester
88017f007f Add preliminary support for XMP3 on DDR5 (#23). Fix an issue with wrong SPD values on DDR5 ES modules 2022-03-25 00:33:42 +01:00
Sam Demeulemeester
aaa2061aec Fix an issue with DDR5 capacity detection 2022-03-24 21:49:56 +01:00
Sam Demeulemeester
b22c032b5a Add support for DDR5 in smbus.c. Major rework of various related functions (#2) 2022-03-24 21:49:56 +01:00
Sam Demeulemeester
8e35753ce8 Fix attempt for benchmark memory allocation (#19) 2022-03-24 21:49:56 +01:00
Sam Demeulemeester
b4bab4f829 Add decoding of DMI structure 17 as helper for SPD decoding. Move DMI display function to disaply.h 2022-03-24 21:49:56 +01:00
Sam Demeulemeester
fa206bb865 Added DDR2 SPD decoding (#2) 2022-03-24 21:49:56 +01:00
Sam Demeulemeester
ec1a880288 Reset methods re-ordering (proven more universal for BIOS/UEFI as an attempt to solve #17) 2022-03-24 21:49:56 +01:00
Sam Demeulemeester
bd5e6f3c6b Bring back the cache & memory benchmark feature (preliminary) 2022-03-24 21:49:56 +01:00
Sam DEMEULEMEESTER
6e57ffec34 Added a lot of modern IMC from Intel's BDW (5th gen) to RPL (13th gen) 2022-03-24 21:49:56 +01:00
Sam DEMEULEMEESTER
eaf1cbeebb Minor cosmectic changes on smbus.c & Added Amazon JEP106 per AWS team request 2022-03-24 21:49:56 +01:00
Sam DEMEULEMEESTER
04c3c485a1 Minor fixes on previously added temperature code 2022-03-24 21:49:56 +01:00
Sam DEMEULEMEESTER
f9690813ca New code base for SMBUS / SPD access (#2) - WIP 2022-03-24 21:49:56 +01:00
Sam DEMEULEMEESTER
de55c0428c Readd hwctrl.h & add argument for reset type 2022-03-24 21:49:56 +01:00
Sam DEMEULEMEESTER
2266151fe6 Early SMBUS functions (#2) & EFI Reset (#17) 2022-03-24 21:49:56 +01:00
Sam DEMEULEMEESTER
b12186b0aa Code cleanup & reindent on smbios.c (#1) 2022-03-24 21:49:56 +01:00
Sam DEMEULEMEESTER
63904403b2 Added preliminary BIOS/EFI SMBIOS table parsing & basic printing (#1) 2022-03-24 21:49:56 +01:00
Sam DEMEULEMEESTER
300fd7c1cf Add temperature display for AMD Zen CPU (#3) 2022-03-24 21:49:56 +01:00
Martin Whitaker
0873e3b60a Include string.h, not memory.h, when using memcpy and memset.
memory.h is an anachronism, and not present on all systems.
2022-03-11 18:07:01 +00:00
Sam DEMEULEMEESTER
4bc3b6a3c8 Add additional reset method 2022-03-08 23:30:31 +01:00
Sam DEMEULEMEESTER
09f5525f33 Add additional reset method 2022-03-08 23:24:25 +01:00
Martin Whitaker
b609c4dd81 Make detection of EHCI asynchronous transfer complete more robust.
Using Interrupt On Completion is not robust, because the interrupt flag
is also set if a short transfer is detected. So we need to poll the
Active flag in the transfer descriptors.
2022-03-06 18:20:53 +00:00
Martin Whitaker
5e2ab9289b Make sure the XHCI private memory is accessible.
The XHCI device index and scratchpad buffers are mapped into high memory,
in order to conserve low memory. They need to be accessible in the virtual
address space to allow us to initialise them. After initialisation. only
the XHCI accesses them.

We also only need to access the data structures in the device private
workspace during initialisation, but keeping separate physical and virtual
addresses for these structures makes the code considerably more complex,
so for now, move these to low memory.
2022-03-05 16:27:24 +00:00
Martin Whitaker
6c79f4d214 Fix communication with low speed devices in OHCI driver (issue #6). 2022-03-04 18:15:17 +00:00
Martin Whitaker
4078b7760e Faster barrier implementation.
The old barrier implementation was very slow when running on a multi-socket
machine (pcmemtest issue 16).

The new implementation provides two options:

  - when blocked, spin on a thread-local flag
  - when blocked, execute a HLT instruction and wait for a NMI

The first option might be faster, but we need to measure it to find out. A
new boot command line option is provided to select between the two, with a
third setting that uses a mixture of the two.
2022-02-28 22:05:21 +00:00
Martin Whitaker
b3d350f454 Add support for 64-bit local APIC addresses found in the MADT.
This is untested, as I don't have any hardware that uses this option.
2022-02-28 22:05:21 +00:00
Martin Whitaker
9fca23105a Don't search for the RDSP at bootparams.acpi_rsdp_addr.
This field is only used internally by the Linux kernel, so will always
be zero when bootparams is passed to us by a bootloader.
2022-02-28 22:05:21 +00:00
Martin Whitaker
da7829d4c3 Ensure the ACPI tables and local APIC are mapped into an accessible region.
We only map the first 4GB of physical address space, so if the ACPI tables
or local APIC are located above 4GB, or are overlaid when we remap something
else (e.g. the video frame buffer), we need to map them to somewhere we can
access. The ACPI tables are only used during startup, but the local APIC
will be needed when we are running tests if we are saving power by halting
idle CPU cores and using a NMI to wake them up.
2022-02-28 22:05:21 +00:00
Martin Whitaker
5211b67e6c Add option to map_region to indicate we only use the region during startup.
This will avoid unnecessary remapping of the ACPI tables if they are
located in the third GB of memory.
2022-02-28 22:05:21 +00:00
Martin Whitaker
a65d6a795d Rename map_device to map_region to better describe its use. 2022-02-28 22:05:21 +00:00
Martin Whitaker
604b22449a Allow device mapping to reuse existing mapped regions when they fully overlap. 2022-02-28 22:05:21 +00:00
Martin Whitaker
e4ad2dfa1b Don't use the top 0.5GB of the 32-bit address space for device mapping.
This region is commonly used by the BIOS for mapping hardware devices,
so we can avoid a lot of remapping if we don't use it.
2022-02-28 22:05:21 +00:00
Martin Whitaker
6b570cd779 Reduce the maximum mapped size of the linear frame buffer.
This is needed for subsequent changes. If we do ever get presented with
a frame buffer larger than 8192x8192 pixels, we'll need to think again
about how to manage it.
2022-02-28 22:05:21 +00:00
Martin Whitaker
f109a5814b Implement EHCI handover to companion controllers.
Low/full speed USB devices attached directly to the root hub must be
rerouted to a companion controller. We can't rely on the BIOS to do
this for us. This requires us to initialise the EHCI device before
initialising any of its companions.

This also allows us to support keyboards attached via a high speed
hub on a system with EHCI plus companions.
2022-02-20 20:21:16 +00:00
Martin Whitaker
f8b82eb0bd Exclude copyright notices from Doxygen file descriptions. 2022-02-19 19:56:55 +00:00
Martin Whitaker
3b183b0bef Add preliminary (untested) code for supporting UHCI. 2022-02-19 16:24:47 +00:00
Martin Whitaker
76adad2fe6 Add ability to generate internal API documentation using Doxygen. 2022-02-19 16:17:40 +00:00
Martin Whitaker
d1382b7a53 Increase timeout delay for starting APs. 2022-02-13 20:25:11 +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
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
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
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
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
17093a96f9 Optimise the AP startup code to reduce the startup delay. 2022-01-31 19:47:32 +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
c5e9fa4e18 Increase maximum number of APs to 256. 2022-01-29 16:13:05 +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
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
4400ec6f17 Rename usbkbd to usbhcd to better reflect the new design. 2022-01-08 23:14:50 +00:00
Martin Whitaker
52a87c5d40 Add support for USB hubs.
This refactors the USB driver code into a more object-oriented design,
with usbkbd.c being the base class and ohci.c and xhci.c being subclasses.
This makes the code that performs USB device enumeration independent of
the host controller.
2022-01-08 23:00:28 +00:00
Martin Whitaker
84da9f7553 Refactor USB driver code to prepare for supporting USB hubs. 2021-12-29 18:17:46 +00:00
Martin Whitaker
a4c62cae97 XHCI: don't scan USB3 ports - keyboards will only be found on USB2 ports. 2021-12-28 16:14:29 +00:00
Martin Whitaker
9785d8f8b9 Map USB controller registers into the reserved area of virtual memory.
This ensures they are accessible when the test is running, and if they
are physically mapped above 4GB.
2021-12-23 17:45:26 +00:00
Martin Whitaker
d9fee4dcbb Flush caches between writing and verifying test data.
Mostly we write and read large chunks of data which will make it likely
that the data is no longer in the cache when we come to verify it. But
this is not always true, and in any case, we shouldn't rely on it.
2021-12-23 11:00:10 +00:00
Martin Whitaker
11c0c6c2f5 Use atomic memory read/write functions in tests.
This ensures compiler optimisations won't interfere with the tests.
2021-12-23 10:07:55 +00:00
Martin Whitaker
eb58a63ad4 XHCI: add device attach time delay after starting the controller. 2021-12-22 19:08:14 +00:00
Martin Whitaker
8069b8724b Initial support for native USB keyboard interface.
This adds support for USB keyboards connected directly to an OHCI
or XHCI controller.
2021-12-22 17:31:06 +00:00
Martin Whitaker
a7d17186f3 Improved PCI configuration space access functions. 2021-12-05 14:15:37 +00:00
Martin Whitaker
8f1d81b65d Add missing includes of stdbool.h.
To ensure we aren't dependent on the order of inclusion.
2021-12-05 13:50:25 +00:00
Martin Whitaker
ec676ccab2 Add debug trace for ACPI RSDP search results. 2020-12-11 16:18:45 +00:00
Martin Whitaker
bb667b600f Use ACPI RSDP address from boot_params if provided by bootloader. 2020-12-11 16:18:04 +00:00
Martin Whitaker
1d2bf57403 Improve and fix scanning for ACPI tables. 2020-12-11 13:27:05 +00:00
Martin Whitaker
27c5fe363f Add startup option to enable/disable SMP. 2020-12-10 13:51:39 +00:00
Martin Whitaker
725435d5c7 Add support for 24bpp frame buffer. 2020-07-09 15:51:04 +01:00
Martin Whitaker
366e7a1af4 Improve code readability. 2020-06-30 13:58:33 +01:00
Martin Whitaker
7d00dbe26a Remove duplicate EFI table definitions. 2020-06-30 13:57:15 +01:00
Martin Whitaker
9492c086fe Move boot_params definitions into separate header file. 2020-06-29 12:09:13 +01:00
Martin Whitaker
fbd3376668 Initial commit. 2020-05-24 21:30:55 +01:00