2016-04-14 07:04:34 +07:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
|
|
|
|
#include <asm/setup.h>
|
|
|
|
#include <asm/bios_ebda.h>
|
|
|
|
|
|
|
|
void __init x86_early_init_platform_quirks(void)
|
|
|
|
{
|
2016-12-10 03:57:38 +07:00
|
|
|
x86_platform.legacy.i8042 = X86_LEGACY_I8042_EXPECTED_PRESENT;
|
2016-04-14 07:04:34 +07:00
|
|
|
x86_platform.legacy.rtc = 1;
|
x86/boot: Reorganize and clean up the BIOS area reservation code
So the reserve_ebda_region() code has accumulated a number of
problems over the years that make it really difficult to read
and understand:
- The calculation of 'lowmem' and 'ebda_addr' is an unnecessarily
interleaved mess of first lowmem, then ebda_addr, then lowmem tweaks...
- 'lowmem' here means 'super low mem' - i.e. 16-bit addressable memory. In other
parts of the x86 code 'lowmem' means 32-bit addressable memory... This makes it
super confusing to read.
- It does not help at all that we have various memory range markers, half of which
are 'start of range', half of which are 'end of range' - but this crucial
property is not obvious in the naming at all ... gave me a headache trying to
understand all this.
- Also, the 'ebda_addr' name sucks: it highlights that it's an address (which is
obvious, all values here are addresses!), while it does not highlight that it's
the _start_ of the EBDA region ...
- 'BIOS_LOWMEM_KILOBYTES' says a lot of things, except that this is the only value
that is a pointer to a value, not a memory range address!
- The function name itself is a misnomer: it says 'reserve_ebda_region()' while
its main purpose is to reserve all the firmware ROM typically between 640K and
1MB, while the 'EBDA' part is only a small part of that ...
- Likewise, the paravirt quirk flag name 'ebda_search' is misleading as well: this
too should be about whether to reserve firmware areas in the paravirt case.
- In fact thinking about this as 'end of RAM' is confusing: what this function
*really* wants to reserve is firmware data and code areas! Once the thinking is
inverted from a mixed 'ram' and 'reserved firmware area' notion to a pure
'reserved area' notion everything becomes a lot clearer.
To improve all this rewrite the whole code (without changing the logic):
- Firstly invert the naming from 'lowmem end' to 'BIOS reserved area start'
and propagate this concept through all the variable names and constants.
BIOS_RAM_SIZE_KB_PTR // was: BIOS_LOWMEM_KILOBYTES
BIOS_START_MIN // was: INSANE_CUTOFF
ebda_start // was: ebda_addr
bios_start // was: lowmem
BIOS_START_MAX // was: LOWMEM_CAP
- Then clean up the name of the function itself by renaming it
to reserve_bios_regions() and renaming the ::ebda_search paravirt
flag to ::reserve_bios_regions.
- Fix up all the comments (fix typos), harmonize and simplify their
formulation and remove comments that become unnecessary due to
the much better naming all around.
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2016-07-21 14:53:52 +07:00
|
|
|
x86_platform.legacy.reserve_bios_regions = 0;
|
2016-04-14 07:04:41 +07:00
|
|
|
x86_platform.legacy.devices.pnpbios = 1;
|
2016-04-14 07:04:34 +07:00
|
|
|
|
|
|
|
switch (boot_params.hdr.hardware_subarch) {
|
2016-04-14 07:04:36 +07:00
|
|
|
case X86_SUBARCH_PC:
|
x86/boot: Reorganize and clean up the BIOS area reservation code
So the reserve_ebda_region() code has accumulated a number of
problems over the years that make it really difficult to read
and understand:
- The calculation of 'lowmem' and 'ebda_addr' is an unnecessarily
interleaved mess of first lowmem, then ebda_addr, then lowmem tweaks...
- 'lowmem' here means 'super low mem' - i.e. 16-bit addressable memory. In other
parts of the x86 code 'lowmem' means 32-bit addressable memory... This makes it
super confusing to read.
- It does not help at all that we have various memory range markers, half of which
are 'start of range', half of which are 'end of range' - but this crucial
property is not obvious in the naming at all ... gave me a headache trying to
understand all this.
- Also, the 'ebda_addr' name sucks: it highlights that it's an address (which is
obvious, all values here are addresses!), while it does not highlight that it's
the _start_ of the EBDA region ...
- 'BIOS_LOWMEM_KILOBYTES' says a lot of things, except that this is the only value
that is a pointer to a value, not a memory range address!
- The function name itself is a misnomer: it says 'reserve_ebda_region()' while
its main purpose is to reserve all the firmware ROM typically between 640K and
1MB, while the 'EBDA' part is only a small part of that ...
- Likewise, the paravirt quirk flag name 'ebda_search' is misleading as well: this
too should be about whether to reserve firmware areas in the paravirt case.
- In fact thinking about this as 'end of RAM' is confusing: what this function
*really* wants to reserve is firmware data and code areas! Once the thinking is
inverted from a mixed 'ram' and 'reserved firmware area' notion to a pure
'reserved area' notion everything becomes a lot clearer.
To improve all this rewrite the whole code (without changing the logic):
- Firstly invert the naming from 'lowmem end' to 'BIOS reserved area start'
and propagate this concept through all the variable names and constants.
BIOS_RAM_SIZE_KB_PTR // was: BIOS_LOWMEM_KILOBYTES
BIOS_START_MIN // was: INSANE_CUTOFF
ebda_start // was: ebda_addr
bios_start // was: lowmem
BIOS_START_MAX // was: LOWMEM_CAP
- Then clean up the name of the function itself by renaming it
to reserve_bios_regions() and renaming the ::ebda_search paravirt
flag to ::reserve_bios_regions.
- Fix up all the comments (fix typos), harmonize and simplify their
formulation and remove comments that become unnecessary due to
the much better naming all around.
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2016-07-21 14:53:52 +07:00
|
|
|
x86_platform.legacy.reserve_bios_regions = 1;
|
2016-04-14 07:04:36 +07:00
|
|
|
break;
|
2016-04-14 07:04:34 +07:00
|
|
|
case X86_SUBARCH_XEN:
|
|
|
|
case X86_SUBARCH_LGUEST:
|
2016-12-10 03:57:38 +07:00
|
|
|
x86_platform.legacy.devices.pnpbios = 0;
|
|
|
|
x86_platform.legacy.rtc = 0;
|
|
|
|
break;
|
2016-04-14 07:04:34 +07:00
|
|
|
case X86_SUBARCH_INTEL_MID:
|
2016-04-14 07:04:46 +07:00
|
|
|
case X86_SUBARCH_CE4100:
|
2016-04-14 07:04:45 +07:00
|
|
|
x86_platform.legacy.devices.pnpbios = 0;
|
2016-04-14 07:04:34 +07:00
|
|
|
x86_platform.legacy.rtc = 0;
|
2016-12-10 03:57:38 +07:00
|
|
|
x86_platform.legacy.i8042 = X86_LEGACY_I8042_PLATFORM_ABSENT;
|
2016-04-14 07:04:34 +07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (x86_platform.set_legacy_features)
|
|
|
|
x86_platform.set_legacy_features();
|
|
|
|
}
|
2016-04-14 07:04:41 +07:00
|
|
|
|
|
|
|
#if defined(CONFIG_PNPBIOS)
|
|
|
|
bool __init arch_pnpbios_disabled(void)
|
|
|
|
{
|
|
|
|
return x86_platform.legacy.devices.pnpbios == 0;
|
|
|
|
}
|
|
|
|
#endif
|