Commit Graph

54 Commits

Author SHA1 Message Date
Stefan Weil 6bcacf7d19 Fix typos found by codespell
Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-10-09 13:34:28 -04:00
Kevin O'Connor ed675ad419 Eliminate FUNCFSEG - only force portions of inline asm to f-segment
The FUNCFSEG macro was introduced to force a C function into the
f-segment.  This was needed for some C functions that used inline
assembler that contained some 16bit code.  Instead of forcing the
entire C function into the f-segment, just force the small subset of
inline assembler into the f-segment.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-12-03 13:06:24 -05:00
Kevin O'Connor eb88bf7db5 build: Support declaring 32bit C functions that must reside in the f-segment
Add support for a FUNCFSEG macro that will force a "32bit flat" C
function to be located in the f-segment.  This is useful for 32bit
code with inline assembler that thunks to 16bit mode.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-10-11 13:41:53 -04:00
Kevin O'Connor ab482e0d6c build: Get fixed address variables from 32bit compile pass (not 16bit)
Update the layoutrom.py build script so that fixed address sections
can come from the 32bit compiled C code.  Update the C code so that
all VAR16FIXED variables instead use the new VARFSEGFIXED which is
defined in 32bit mode.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-06-11 16:22:51 -04:00
Kevin O'Connor b4f4d331e0 Move definition of struct segoff_s from farptr.h to types.h.
The segoff_s definition is used by a number of header files that would
not otherwise need farptr.h, so move it to a more central location.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-18 20:48:34 -04:00
Kevin O'Connor e097a75ef0 Introduce and convert pmm code to use standard list helpers.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-06-08 21:49:12 -04:00
Kevin O'Connor 2af52da5ad Add VARVERIFY32INIT attribute for variables only available during "init".
Add a build check to verify certain variables are only reachable via
the 32bit "init" code.  This can be used as a mechanism to enforce
certain data (and code that accesses that data) as only available
during POST.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-03-08 19:55:26 -05:00
Kevin O'Connor 6afc6f8fbb Don't relocate "varlow" variable references at runtime.
Since the final location of the "varlow" variables are known at build
time, link the final locations into the binary during the build.  The
16bit code was already done at link time - update the build so the
32bit code is also done at link time.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-02-19 21:56:59 -05:00
Kevin O'Connor 89a2f96de4 Convert VAR16VISIBLE, VAR16EXPORT, and VAR32VISIBLE to VARFSEG.
Convert all users of the alternative variable exports to VARFSEG.
There isn't a significant distinction between the existing types of
exports, so it's simpler to just use one type going forward.

The new VARFSEG declaration is only emitting when in 32bit mode, so
update and move some variables as needed.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-02-18 23:36:03 -05:00
Kevin O'Connor 4195349d78 Introduce VARFSEG for variables that will reside in the f-segment.
Introduce a variable declaration that will force variables (that are
compiled in 32bit mode) to be emitted into the f-segment.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-02-18 23:09:01 -05:00
Kevin O'Connor c924344e18 Clarify build generated "zone low" values.
Rename datalow_base (and similar) to zonelow_base, and datalow_start
(and similar) to varlow_start.  This helps distinguish between the
bounds for the runtime dynamic memory pool and the compile time global
variables.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-02-17 13:58:28 -05:00
Kevin O'Connor 30e6af0dcd Fix 'union u64_u32_u' member names.
Use 'lo' to mean the low bits and 'hi' to mean the high bits of a
64bit value.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-09-15 12:17:37 -04:00
Kevin O'Connor d3e4367529 Don't restrict VISIBLEx C functions to only x mode.
Since SeaBIOS has been updated to use "_cfuncx_" prefixes when calling
cross-mode C functions, there is no reason to restrict an exported C
function to only the given mode.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-05-28 23:21:43 -04:00
Kevin O'Connor 46b82624c9 Add mechanism to declare variables as "low mem" and use for extra stack.
Add a mechanism (VARLOW declaration) to make a variable reside in the
low memory (e-segment) area.  This is useful for runtime variables
that need to be accessed from 16bit code and need to be modifiable
during runtime.

Move the 16bit "extra stack" from the EBDA to the low memory area
using this declaration mechanism.  Also increase the size of this
stack from 512 bytes to 2048 bytes.

This also reworks tools/layoutrom.py a bit.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-05-20 18:10:38 -04:00
Kevin O'Connor f3fe3aa7a0 Require a "_cfuncXX_" symbol prefix for inter-mode c function references.
The compiler can get confused when referencing a C function in a
different mode.  (It reasonably assumes that the C function in the
current mode is desired.)  To avoid this compiler confusion, introduce
symbol prefixes (_cfunc16_, _cfunc32flat_, _cfunc32seg_) that must be
used on C function symbols that are referenced from other compilation
modes.

This makes it less likely compiler confusion will occur.  It will also
makes it easier to implement and use vtable like operation structures.
2010-12-05 12:38:33 -05:00
Kevin O'Connor d1b4f967ea Separate out init code from the rest of the 32bit flat code.
Enhance tools/layoutrom.py code so that it can detect which sections
are used from the "32bit flat" runtime code.  All other "32bit flat"
sections can then be assured to be initialization code only.

This is in preparation for relocating the 32bit initialization code.
2010-09-15 21:38:16 -04:00
Kevin O'Connor f9a774cc58 Add __attribute__((__malloc__)) declaration to internal malloc funcs. 2010-04-17 16:58:32 -04:00
Kevin O'Connor d7eb27efa3 Don't move EBDA while an optionrom is running (CONFIG_THREAD_OPTIONROMS).
Moving the ebda while an optionrom is running could confuse it.  So,
avoid doing that.
2010-03-20 18:17:19 -04:00
Kevin O'Connor 7c1b18655e Reduce #ifs by weeding out some cross-chunk function definitions.
Reduce the need for placing #if guards around functions that are
marked as VISIBLE in another code chunk by declaring the functions as
"weak" when they are not needed.

It's still necessary to ensure that no C code references the data from
a different chunk (or an -fwhole-program compile might try to keep a
local reference).
2010-01-03 18:33:00 -05:00
Kevin O'Connor 1ca05b0f39 Be sure to add "void" to all function prototypes that take no args.
Omitting "void" leads to a K&R style declaration which was not intended.
2010-01-03 17:43:37 -05:00
Kevin O'Connor fdca41825d Force a link error if a function is used from the wrong code chunk.
Force functions intended for other code segments to be discarded
    during link - this will cause a link error if it used.
Clean up rom layout code to ensure discarded sections are not used.
2010-01-01 13:05:23 -05:00
Kevin O'Connor dad41d9f21 Add __noreturn define for __attribute__((noreturn)). 2010-01-01 13:05:23 -05:00
Kevin O'Connor 871e0a0c14 Add support for 32bit PCI BIOS entry.
Create a new code blob (code32seg) with support for 32bit functions
    that need to utilize explicit segment accesses.
This code blob uses global variables relative to %gs and with a
    dynamic code offset (determined by get_global_offset()).
Add BIOS32 structure and code.
Add code for 32bit PCI BIOS code.
2009-12-30 12:14:53 -05:00
Kevin O'Connor 52a300f1c1 Introduce MODESEGMENT define; rename VISIBLE32 to VISIBLE32FLAT.
Prepare for support of segmented 32bit code.
Add new MODESEGMENT definition, and clarify existing 32bit mode defs.
2009-12-26 23:32:57 -05:00
Kevin O'Connor 6aee52dd45 Replace clock conversion constants with defines.
Simplify and name the clock multiplier constants.
2009-09-27 20:07:40 -04:00
Kevin O'Connor 372e071ed4 Rename VAR16_32 to VAR16VISIBLE.
Sometimes VAR16_32 is used to export a definition to assembler, so
    clarify its naming.
2009-09-09 09:51:31 -04:00
Kevin O'Connor 415d4298df Cleanups for malloc code.
Fix bug where zones over 2gig may fail to allocate.
Add memalign_high() and use for acpi facs allocation.
Misc code cleanups.
2009-08-30 19:19:31 -04:00
Kevin O'Connor 0bf9270aa4 Add Post Memory Manager (PMM) support.
Complete the initial implementation of PMM.
Default new PMM code to be enabled.
Move malloc code from memmap.c to pmm.c.
Define new malloc zones for PMM (ZoneTmpLow and ZoneTmpHigh).
Change default READ/WRITE_SEG macros to use 32bit pointers (the 16bit
    PMM code use "big real" mode and requires 32bit accesses).
Allow pmm allocations to occur during bcv executions also.
Add low-memory clearing before boot.
Also, align the default f-seg memory.
2009-08-01 11:45:37 -04:00
Kevin O'Connor 0b60a062da Unify mode16/32 compiler checks.
Add ASSERT16/ASSERT32 macros to farptr.h.
Use those macros in place of open-coded checks.
Add "noreturn" attribute to functions to reduce compiler warnings.
Add ASSERT32 to smp_probe() to eliminate 16bit assembler warnings.
2009-06-15 23:03:05 -04:00
Kevin O'Connor 942d495dcd Add support for gcc v3.x compilers.
Suppress __attribute__((externally_visible)) when no -fwhole-program
Add switch hack for compilers without -fno-jump-tables
Define memcpy() function (for compilers without -minline-all-stringops).
Define call16_simpint as a macro (a param needs to be inlined).
Make sure s3_resume is only defined in 32bit mode.
2009-06-10 22:44:06 -04:00
Kevin O'Connor c0693941fd Do garbage collection of unused sections.
Implement -ffunction-sections and -fdata-sections in both 32bit and
    16bit code.
Make sure all sections have unique names (even asm and discarded
    sections).
Enhance tools/layoutrom.py script to find all sections reachable from
    exported 16bit code - prune all other sections.
Mark sections with "export" if they can be visible outside of code -
    these sections wont be dropped when pruning unused sections.
2009-06-10 21:56:01 -04:00
Kevin O'Connor 308537650f Move variables from assembler to C code.
Define macro VAR16FIXED for declaring a variable at a fixed location.
Introduce new file src/misc.c, and move non int15 calls from system.c
    to it.
Implement all fixed location variables in C code.
Move IDT/GDT defs to misc.c.  Remove unused gdt entry 1.
2009-01-17 18:49:20 -05:00
Kevin O'Connor 202024a27b Layout fixed area using linker instead of assembler.
The fixed offset requirements of the 16bit code can be done using
    multiple sections and a linker script.  Using the linker allows
    for more flexibility.
Also, have the 16bit code generate sections for every function and
    variable definition.
2009-01-17 10:41:28 -05:00
Kevin O'Connor b1b7c2a1c3 Change license from GPLv3 to LGPLv3.
Change license of contributions from Kevin O'Connor from GPLv3 to
LGPLv3 (or later).  Since the work as a whole is based on Kevin's
contributions and the "bochs bios" which has a license of LGPL (v2 or
later), this effectively makes the work as a whole available under
LGPLv3 (or later).
2009-01-15 20:52:58 -05:00
Kevin O'Connor 92f95b0fec Add more linker protections around variables accessed from 16bit mode.
Rename VAR16 to VAR16_32 -- that macro supports accesses from both
    16bit and 32bit mode.
Introduce a new macro VAR16 that must be present on all global
    variables accessed from 16bit mode.
2008-12-29 20:42:40 -05:00
Kevin O'Connor 4a754b38ee Add linker magic to ensure 16bit variables aren't repeated in 32bit code.
Add VAR16 macro to enable a variable to be available in both 32bit and
    16bit code.  This reduces the occurrences of "#if MODE16".
Also add ASM16 macro to reduce occurrences of "#if MODE16".
2008-12-28 21:37:27 -05:00
Kevin O'Connor 18e38b2923 Improve support for old 16bit resume handlers.
Detect a non-standard CMOS shutdown code during post and run a
    separate resume handler.
Set aside space in the EBDA for the resume handler stack.
Add support for several of the code supported in bochs bios.
2008-12-10 20:40:13 -05:00
Kevin O'Connor 7ab798f907 Always define macro MODE16 - that way it can be used in C conditionals.
When in 32bit mode - just define it to 0.
2008-07-13 11:08:36 -04:00
Kevin O'Connor 276d4a9165 Move acpi code out of rombios32.c; clean up use of fixed memory addresses.
Move acpi code from rombios32.c to acpi.c.
Move all fixed memory addresses used by the code to config.h and
    consistently use a "BUILD_" prefix on the definitions.
Move some pci defs to pci.h - allows access from acpi.c and rombios32.c.
Introduce ALIGN() macro - remove old align function.
2008-06-11 22:47:01 -04:00
Kevin O'Connor 9dd0dd1e4e Auto detect EBDA_SIZE from size of data structure. 2008-05-18 00:03:32 -04:00
Kevin O'Connor 1bb3b5c252 Add full support for drives with more that 2<<32 sectors.
Use 64bit integers for sector and lba values.
2008-05-14 00:43:13 -04:00
Kevin O'Connor ee55c76701 Reduce ide stack usage by reorganizing ata calls.
Break up some functions and play with inlining to reduce stack usage.
2008-05-13 00:18:20 -04:00
Kevin O'Connor 74f9c0879b Use __always_inline to force inlining.
Before, inline was enough to force inlining.
2008-04-13 16:57:16 -04:00
Kevin O'Connor 595fb46812 Add s64 type to types.h. 2008-04-05 10:47:13 -04:00
Kevin O'Connor e51313d90c Update interger types in rombios32 code.
- Make rombios32.c to use the interger types already defined in types.h
- Add u64 typedef

Signed-off-by: Nguyen Anh Quynh <aquynh@gmail.com>
2008-03-12 21:19:34 -04:00
Kevin O'Connor 28fe1bd0f0 Add FIELD_SIZEOF macro to types.h 2008-03-11 22:14:15 -04:00
Kevin O'Connor bc28a2bc4c Force functions marked as inline to always be inlined.
Inline alters stack usage, so don't let gcc uninline.
Also, gcc seems to include multiple copies of uninlined functions when
using -combine.
With inlining forced on, the no null check optimization causes
problems, so disable it.
2008-03-11 19:32:38 -04:00
Kevin O'Connor a4d357638c Port rombios32 code from bochs-bios.
This adds acpi, smbios, pci init, etc.
Changes from original rombios32.c code:
* Header file translation.
* Use common functions already in code (eg, outb, memset, bios_printf,
  usleep)
* Implement trampoline for disabling bios shadowing (rombios32 code
  actually runs in the 0xf0000 area).
* Copy asm code from rombios32start.S to an asm() statement in C
  code.
2008-03-08 15:43:03 -05:00
Kevin O'Connor 47baa3c82c Revert "This patch adds the BIOS support for SMP, ACPI, PCI, SMM, SMBIOS."
This reverts commit 3d02941716.

Conflicts:

	src/post.c
2008-03-08 13:17:16 -05:00
Kevin O'Connor 19786767cf Rename VISIBLE macro for better control.
VISIBLE16 is used to mark functions externally available in 16bit code.
VISIBLE32 is for 32bit functions.
2008-03-05 21:09:59 -05:00