Commit Graph

215 Commits

Author SHA1 Message Date
Chao Li
e99ce97648 Add the 64-bit and 32-bit CC flag
Added a new CC flag into build32 and build64 Makefiles to distinguish
whether compiling to 32-bit or 64-bit code.

[Lionel Debroux: rebased on the memrw functions refactor.]

Signed-off-by: Chao Li <lichao@loongson.cn>
2024-07-22 22:50:15 +02:00
Lionel Debroux
8d966d98f4
Refactor the memrw functions to reduce the redundancy. (#415)
The impact is limited now, but will increase when adding support for more architectures and more bit widths.
2024-07-16 08:55:13 +01:00
Martin Whitaker
778c7b4cc4 Fix the behaviour of sort_pm_map() (issue #392)
The existing algorithm both read and wrote data beyond the end of the
array and, when moving data, moved it in the wrong direction. Replace
it with a bog-standard insertion sort algorithm. The resulting code
is smaller and probably faster, as memmove() is not in-lined.
2024-04-09 20:07:09 +01:00
Lionel Debroux
53ca89f8ae
Add initial NUMA awareness support (#378)
* Add a file containing useful macro definitions, currently a single top-level macro for obtaining the size of an array; use it to replace a sizeof(x) / sizeof(x[0]) construct in system/smbus.c . This requires switching the GCC build mode from C11 to C11 with GCC extensions.

* Initial NUMA awareness (#12) support: parse the ACPI SRAT to build up new internal structures related to proximity domains and affinity; use these structures in setup_vm_map() and calculate_chunk() to skip the work on the processors which don't belong to the proximity domain currently being tested.

Tested on a number of 1S single-domain, 2S multi-domain and 4S multi-domain platforms.

SKIP_RANGE(iterations) trick by Martin Whitaker.
2024-03-13 01:43:26 +01:00
martinwhitaker
20fca09752
Add boot options to perform display rotation and set preferred screen resolution (#383)
* Add boot option to rotate screen display through 90 degrees.

Some machines have a detachable display that can be used in either
portrait or landscape orientations, and require software to rotate
the displayed image accordingly. There is no way to detect the
current orientation through the BIOS, so provide a boot option to
control this. Hopefully we only need to support one (+90 degree)
angle.

Note that the rotate option only works in graphical mode. When booted
by a legacy BIOS using text mode, we have to rely on the BIOS to do
what's necessary.

* Extend boot command line options for display screen control.

Replace "rotate" option with "screen.rhs-up" and "screen.lhs-up" to
allow rotation in either direction. Add a "screen.mode=<w>x<h>"
option to set a preferred width <w> and height <h> for the UEFI
frame buffer. Also allow "screen.mode=bios" to use the default
UEFI frame buffer resolution.

* Add more debug output for EFI frame buffer mode.

* Replicate command line parsing of screen options in efisetup.c.

Trying to do it only once in screen.c didn't work, because static
variables initialied to zero are placed in the bss section, and we
don't zero the bss section until after efisetup() is executed.

The resulting code is in fact smaller, because the compiler can
optimise better when everything is local.

* Add a boot command line option for efisetup debug.

* Improve EFI debug test screen pattern.

* Document the new screen and efidebug boot command line options.

* Fix typo in README.
2024-03-04 14:49:13 +01:00
Sam Demeulemeester
2d3b14ed1a Add detection for various JEDEC Manufacturers 2024-01-07 15:20:19 +01:00
Sam Demeulemeester
5dde13b0a1
Preliminary ECC support for AMD Zen CPUs (#353)
* Initial commit for ECC support. Preliminary support for AMD Zen.

* Clear ECC registers at startup

* Add config flag (enable_ecc_polling) to toggle ECC polling. (Currently disabled by default for v7 release)
2023-11-29 12:53:05 +01:00
Lionel Debroux
9b9c65b968
Reduce padding and relocations (#355)
* Optimize the JEP106 list by using __attribute__((packed)) to remove padding. The x86 & x86_64 series support unaligned accesses just fine, after all, and this is not remotely a hot path.

* Optimize several string-related constructs by switching to fixed-length char arrays, which avoids pointers + relocations.

* app/interrupt.c: array of different-length strings, but most of those are lengthy enough for this to be a clear win, especially on x86_64;
* system/usbhcd.c: array of same-length strings;
* tests/tests.h: array of structs containing same-length strings.

* Reduce the size of the list of tests by using a narrower type for the cpu mode, which reduces padding.
2023-11-29 12:45:17 +01:00
Jonathan Teh
50f59d411d
cpuinfo: Fix VIA Samuel 2 L2 cache (#341)
* cpuinfo: Fix VIA Samuel 2 L2 cache (Hardcode to 64K)
2023-09-16 18:30:04 +02:00
Sam Demeulemeester
03b6cbe4e4 Add IMC polling for AMD Rembrandt
Refactor cpuinfo() for AMD Family 19h CPUs and add detection for AMD Chagall, Storm Peak, Rembrandt, Phoenix and Granite Ridge
2023-06-01 22:00:02 +02:00
Jonathan Teh
a1ef11c3ba
cpuinfo: Add support for Vortex86 (#290)
* cpuinfo: Add support for Vortex86

Hardcode cache for family 5, use CPUID cache info for family 6.

* cpuinfo: Add support for Vortex86EX

The EX does not have brand string so hardcode name and cache.

* In determine_cache_size(), add an additional test to ensure that only
Vortex86 CPUs are handled, allowing Zhaoxin CPUs to fall through.
2023-05-20 20:10:05 +02:00
Sam Demeulemeester
de4f4768fc Fix various temperature-related issues on older Atom CPUs
Also, remove the no_temperature var to keep only the enable_temperature flag
Older Atom still have the enable_temperature flag hard-coded to false until further tests are done
2023-05-18 16:03:48 +02:00
Sam Demeulemeester
9e3958714b
Add support for MMIO UART console (#300)
8/16/32-bit MMIO supported, with configuration options as kernel parameters.
2023-05-12 15:49:00 +02:00
Sam Demeulemeester
7aeac7271f
Add Memory Controller Registers polling to get current DRAM Timings/Frequency (#306)
Read the memory controller configuration (instead of just relying on SPD data) to get the actual live settings.

Currently supported platforms:
* Intel SNB to RPL (Core 2nd Gen to Core 13th Gen) - Desktop only (no Server nor Mobile)
* AMD SMR to RPL (Zen to Zen4) - Desktop only (no Server, Mobile nor APU).


Individual commits below for archival:

* First functions skeleton for reading IMC/ECC Registers

* Change directory name from 'chipsets' to 'mch' (Memory Controller Hub)

* Add Intel HSW and fix new files encoding

* First Intel HSW IMC implementation

* Add an option to disable MCH registers polling

* Remove old include from Makefiles

* Better Makefile and padding fixes

* Statically init 'imc' struct to generate string relocation record

* Small typos & code fixes

* Add IMC support for Intel Core 6/7/8/9th Gen (SKL/KBL/CFL/CML) This is a bit more complex than Haswell and below because MMIO switched to 64-bit with Skylake (lot of) betatesting needed

* Add IMC read support for Intel SNB/IVB (2nd/3rd gen Core)

* Fix hard-lock on Intel SNB/IVB due to wrong access type on MCHBAR pointer

* Move AMD SMN Registers & offsets to a specific header file

* Add IMC Read support for AMD Zen/Zen2 CPUs

* Change 'IMC' to 'MCH' in Makefiles to match actual mch/ directory

* Add IMC Reading support for Intel ADL&RPL CPUs (Core Gen12&13)

* Add support for Intel Rocket Lake (Core 11th Gen) and AMD Vermeer

* Add IMC reading for AMD Zen4 'Raphael' AM5 CPUs

* Various Cleanup #1 
Change terminology from Intel-based 'MCH' (Memory Controller Hub) to more universal 'IMC' (Integrated Memory Controller) Integrate imc_type var into imc struct. Remove previously created AMD SNM header file

* Various Cleanup 2

* Change DDR5 display format for IMC specs
DDR5 Freq can be > 10000 and timings up to 63-127-127-127, which overwflow the available space.
This commit remove the raw frequency on DDR5 (which may be incorrect due to Gear mechanism) and leave a bit of space to display the Gear engaged in the future
2023-05-12 15:33:28 +02:00
Sam Demeulemeester
1f1fe5bfe8 Generalize the SMBus IO Enable quirk on all Intel ICHs
This has been tested safe on every ICH since the very first one by CPU-Z.
It also solves various SMBus access issues on Mobile PCHs (like #157)
2023-04-26 00:42:58 +02:00
Sam Demeulemeester
0fd2e4c37a Add support for Intel AlderLake-N CPUs 2023-04-24 00:29:37 +02:00
Sam Demeulemeester
fa4e903509 Fix APIC Timer detection fail on some modern mobile/embedded PCH
On some modern ULV cores (eg: Gracemont), the 2 following I/O reads to check APIC Timer working status are fused in the frontend, leading to the same value being reported twice and the code falling back to the (unusually disabled on these platforms) PIT timer.

Whether this behavior is intentional or not is unknown.

As usleep/sleep is not available at this point, a dirty delay is added between the two reads.
2023-04-23 22:45:27 +02:00
Sam Demeulemeester
5cbcd2046b Add 'Jade Star' & 'InnoDisk' JEDEC Manufacturers 2023-03-09 23:08:01 +01:00
Jonathan Teh
dcca756e48
[cpuinfo] Fix old CPUs (P5/P6-class) name and cache info (#267)
* cpuinfo: Fix WinChip and Cyrix/NSC CPU name and cache info

Always populate the cache info from extended CPUID, it is not used for
Intel CPUs, even though it is present, and is useful for non-Intel CPUs.

Fix the CPU name and cache sizes for Centaur and Cyrix/NSC CPUs without
brand string, which are the WinChip C6 and all Cyrix CPUs except the
Media GXm.

For the Media GXm and Geode GXm/GXLV/GX1, which are available with both
Cyrix and NSC vendor strings, hardcode the L1 cache size. The Geode GX2
uses standard cache info.

* Add 'Intel' in CPU names for older CPUs

* Add 'Transmeta' and 'IDT' in CPU names for older CPUs
-------

Co-authored-by: Sam Demeulemeester <github@x86-secret.com>
2023-03-03 13:21:27 +01:00
Sam Demeulemeester
262aac4f85
[SMBUS] Add support for ALi M1533/1535/1543C (#273)
Closes #126
2023-02-20 18:31:33 +01:00
Sam Demeulemeester
66bd82f12a
[SMBus] Add support for ALi M1563 Southbridge (#272) 2023-02-19 17:29:56 +01:00
Sam Demeulemeester
ee0c400821 [SMBUS] Add support for VIA VT8233 Southbridge 2023-02-18 19:01:59 +01:00
Sam Demeulemeester
e1fc02bfe0 [SMBUS] Add support for VIA VT8233A Southbridge 2023-02-18 18:58:34 +01:00
Sam Demeulemeester
1a38f513de
[Temperature] Add support for CPUs with specific TjMax (#269)
Solve an issue where reading MSR_IA32_TEMPERATURE_TARGET makes the system crash (e.g. Early Mobile Yonah)
2023-02-18 18:43:38 +01:00
Sam Demeulemeester
22663f89bb
Add support for AMD K8 temperature reporting. (#268)
Add various quirks to handle AMD temp sensors erratas
2023-02-13 22:29:17 +01:00
Sam Demeulemeester
c38b0cbc5f [SMBUS] Add support for nVidia nForce 3 2023-02-13 19:43:09 +01:00
Sam Demeulemeester
dfc41f7196 Solve incorrect core/thread count on some VIA CPUs
No Cyrix / VIA / CentaurHauls / Zhaoxin CPUs support HT, so disable it.
2023-02-11 19:00:36 +01:00
Jonathan Teh
8305d47675
Support cache and temperature info for VIA/Centaur/Zhaoxin CPUs (#259)
* Support cache and temperature info for VIA/Centaur/Zhaoxin CPUs

Use extended CPUID for VIA C3/C7/Nano cache information.

Use MSR reads for Nano/Zhaoxin and VIA C7 processor temperature.

Tested on VIA C7-D 1.5GHz.

* Small code conventions fixes

* Fix overallocation of cpuid_cache_info_t union (From PR #263)

---------

Co-authored-by: Sam Demeulemeester <github@x86-secret.com>
2023-02-10 22:32:31 +01:00
Jonathan Teh
a47f681151 smbus: Add support for VIA VT8237
Tested on Jetway J7F2 with VT8237R+.

Signed-off-by: Jonathan Teh <jonathan.teh@outlook.com>
2023-02-05 08:22:13 +01:00
Sam Demeulemeester
485bfa46a3
Add a quirk to disable SMP on SuperMicro X10SDV (#244) 2023-01-30 16:47:54 +01:00
Sam Demeulemeester
b15a8bb632 Add SPD support for ATI SB400 Southbridge 2023-01-23 16:09:32 +01:00
martinwhitaker
327495ec61
Allow use on headless EFI systems. (#242)
A headless EFI system may have no GOP devices. In this case, disable
output to the physical display, but continue to write to the shadow
buffer. This allows operation via a serial console.
2023-01-23 15:50:52 +01:00
Sam Demeulemeester
10e8435604 Add SPD support for legacy VIA Southbridges (VT82C686A/B & VT8235)
(From PR #236)

Author: Corentin Labbe clabbe.montjoie@gmail.com
Co-developed-by: Lionel Debroux lionel_debroux@yahoo.fr
2023-01-23 15:01:48 +01:00
Martin Whitaker
a1af48a8cf Fix and improve documentation in heap.h (issue #232) 2023-01-03 11:55:51 +00:00
Martin Whitaker
aaa0cffaa6 Use virtual memory base address when probing USB controllers (issue #180)
We still want to display the physical address for debug purposes, but
must access the controller via the possibly remapped virtual address.
2022-10-07 13:06:42 +01:00
Martin Whitaker
66b1389348 Revert workaround for issue #6 and issue #71 (commit 3a10701).
The early USB handoff is a better fix for those issues.
2022-10-07 09:33:23 +01:00
martinwhitaker
407fb811c2
Take ownership of all USB controllers before probing for devices. (#167)
When two controllers are attached to a physical port (e.g. in the
case of EHCI and its companion controllers, problems can occur if
the BIOS still has control of one controller when we try to use the
other one. So perform a first pass to scan the PCI bus and take
ownership of and reset all the controllers we find, and perform a
second pass to initialise the controllers and probe for attached
devices.

As we don't support hot plugging, split the second pass into two,
with the first probing the EHCI controllers and handing over any
low and full speed devices to the companion controllers, and the
second probing the remaining controller types.
2022-10-07 09:32:09 +01:00
Lionel Debroux
1c4d7f4089
Document PCI vendor and device IDs for several SMBus controller models from SiS, EFAR and ALi; move the PCI vendor ID defines from system/smbus.h to system/pci.h and add several vendor IDs; use the defines from system/pci.h in system/hwquirks.c. (#154)
Inspired by #126.
2022-09-14 18:57:10 +02:00
Martin Whitaker
c41159084d Guard against unsupported or invalid USB controller types. 2022-09-09 19:48:59 +01:00
Sam Demeulemeester
03a5222ee2 Add support for Zen4/AM5 DDR5 SPD 2022-09-09 18:09:13 +02:00
Martin Whitaker
f265d1f1c5 Fix EHCI and XHCI drivers to handle USB1 hubs (issue #156) 2022-09-08 18:09:43 +01:00
Sam Demeulemeester
18f12116c0 Fix a rare capacity detection issue with DDR3 modules built using 3 or 4 ranks 2022-08-29 02:50:11 +02:00
Sam Demeulemeester
385f912776 Fix date decoding issue: week 53 is actually valid for some years 2022-08-29 02:12:05 +02:00
Sam Demeulemeester
6799bfba3c Fix timings decoding issues with DDR3 XMP Modules. Add quirks for early modules based on XMP Draft 2022-08-29 01:59:36 +02:00
01e3
540270513f smbus: introduce and use bcd_to_ui8 helper function
Introduce bcd_to_ui8 for converting BCD into uint8_t.

Currently, smbus.c is the only user of this code so I placed it there.
Once (if?) there are more, we may want to move it to a dedicated ".h" file.

Replace all BCD conversion in smbus.c with a call to bcd_to_ui8().

No change in the binary output.
2022-08-28 18:14:41 +02:00
01e3
5686da4b1d smbus: optimize parse_spd_* functions
Convert calling / return convention for all parse_spd_* functions from
returning the value of spd_info structure to updating the received
reference. This also allows to move / remove some boilerplate code,
like initializing spdi/curspd and setting slot_num.

At the end, print_smbus_startup_info wants curspd to be updated,
so we can do this in a more efficient way.

Before:
      text       data        bss      total filename
     10784       3887         18      14689 build32/system/smbus.o
     10486       4399         18      14903 build64/system/smbus.o

     79353      51101      13088     143542 build32/memtest_shared
     78438      58077     294432     430947 build64/memtest_shared

After:
      text       data        bss      total filename
     10379       3871         18      14268 build32/system/smbus.o
      9833       4399         18      14250 build64/system/smbus.o

     78937      51101      13088     143126 build32/memtest_shared
     77782      58077     294432     430291 build64/memtest_shared

gcc-11.3.0.
2022-08-28 18:14:41 +02:00
01e3
43b0f64ddb smbus: refactor SPD SKU (part number) handling
Replace SPD SKU reading code repeated multiple times across
all the parse_spd_* functions with a dedicated read_sku function.

Convert spd_infos.sku from len+data into classic NULL-terminated C-string.
Takes the same space, but simplifies handling. Also, use char instead of
uint8_t so no conversion is needed when printing.

Change the way how the end of part number is handled. Stop on the first
non-ASCII character and then trim all trailing spaces. This allows SKUs
with two (or more) spaces inside the name to be handled properly.

Finally, fix incorrect / inconsistent part number length handling, with
the following end result:
 - parse_spd_sdram: 18 [73-90] (no change)
 - parse_spd_rdram: 18 [73-90] (no change)
 - parse_spd_ddr:   18 [73-90] (no change)
 - parse_spd_ddr2:  18 [73-90] (no change)
 - parse_spd_ddr3:  20+1=21 -> 18 [128-145]
 - parse_spd_ddr4:  20+1=21 -> 20 [329-348]
 - parse_spd_ddr5:  29+1=30 -> 30 [521-550] (technicaly no change)

Before:
      text       data        bss      total filename
     13143       3795         18      16956 build32/system/smbus.o
     11735       4359         18      16112 build64/system/smbus.o

     81705      51133      13088     145926 build32/memtest_shared
     79686      58109     294432     432227 build64/memtest_shared

After:
      text       data        bss      total filename
     10784       3887         18      14689 build32/system/smbus.o
     10486       4399         18      14903 build64/system/smbus.o

     79353      51101      13088     143542 build32/memtest_shared
     78438      58077     294432     430947 build64/memtest_shared

gcc-11.3.0.
2022-08-28 18:14:41 +02:00
Sam Demeulemeester
0f8981412c
Various fixes on SPD decoding algorithms (#152)
* [DDR5] Fix rounding errors on SPD Timings

* [DDR5] Add a rounding factor of ~0.3% according to JEDEC to solve the last rounding issue found on NETAC Modules

* [DDR5] Add missing package ranks per channel parameter in total module capacity algorithm

* [DDR4] Fix rounding issues in SPD timings & frequency

* [DDR3] Fix rounding issues in SPD timings & frequency decoding. Check XMP Profile #2. Add a quirk for Kingston based on very early XMP 1.0 specs

* [DDR2] Fix CAS detection & rounding issues in SPD timings w/ EPP

* [DDR] Correct SPD timings rounding issues & add support for x.5 CAS latencies

* [SDR] Correct SPD Timings decoding due to rounding errors

* Add various JEP106 Manufacturers found while debugging

* Update timings display function to handle x.5 CAS
2022-08-26 21:56:12 +02:00
Sam Demeulemeester
02702fa8c5 Change check to be sure Extended Topology Information (CPUID.0BH:EBX[15:0]) is supported 2022-08-15 22:26:22 +02:00
a1346054
9660eead4e
Simple maintenance improvements (#145)
* Fix typos

* Add missing final newline

* Trim trailing whitespace
2022-08-15 17:51:48 +02:00