1
0
mirror of https://github.com/taigrr/gopher-os synced 2025-01-18 04:43:13 -08:00

86 Commits

Author SHA1 Message Date
Achilleas Anagnostopoulos
fe6c8f7293 acpi: implement AML multi-pass parser 2018-03-09 07:08:36 +00:00
Achilleas Anagnostopoulos
98fe98bc83 acpi: implement reader abstraction for AML in-memory byte-streams 2018-03-09 07:08:36 +00:00
Achilleas Anagnostopoulos
b00fff0e39 acpi: define tree-based structure for storing parsed AML entities
ACPI entity definitions form a tree whose roots are a sequence of
pre-defined namespace objects. The parser stores all AML entities using
a space-optimized structure (Object). These objects are organized into a
tree via the ObjectTree structure.

Instead of storing pointers to other objects (i.e. siblings, children or
parent), objects use uint32 indices to objects managed by the
ObjectTree. This has the nice advantage of reducing the memory
requirements for our tree in half when running on 64-bits (4-bytes per
index vs 8-bytes per pointer) while also allowing us to recycle objects
that are explicitly freed by the parser.
2018-03-09 07:08:31 +00:00
Achilleas Anagnostopoulos
851011f957 acpi: define parser tables for decoding AML opcodes
The opcode tables establish a 2-level mapping between AML opcodes (regular
or extended) and a secondary table that allows the parser to decode each
opcode. This information includes:
 - the opcode name
 - the opcode flags (e.g. specifies a named object or parsing must be
 deferred to a later pass)
 - the expected arguments for each opcode and their types.
2018-02-28 19:41:51 +00:00
Achilleas Anagnostopoulos
ca1682c431 acpi: define helper functions for working with opcode groups 2018-02-27 08:37:55 +00:00
Achilleas Anagnostopoulos
b1e959ec4d acpi: define list of AML opcodes
The list provides a uniform mapping for regular (one byte), extended
(0x1b + one byte) opcodes as well as some "internal" opcodes that will be
used by the parser to represent method calls, named fields and resolved
named object references.
2018-02-27 08:14:42 +00:00
Achilleas Anagnostopoulos
80bd263fc9 acpi: remove broken AML parser implementation
The existing parser implementation has several issues and will, in many
cases incorrectly parse AML bytestreams that contain (among other
things):
- ambiguous method calls (same method name defined in multiple scopes)
- bank fields
- buffer fields where the length arg contains a method call
- named objects containing one or more '^' prefixes when defined inside
nested Scope elements (e.g. Scope(_SBRG){ Device(^PCIE){...} })

Unfortunately, these issues were discovered quite late while working on
the AML interpreter and while an attempt was made to correct some of
these (see previous commits), it turns out that the current codebase
cannot be refactored to fix all issues.

I have therefore decided to get rid of the current implementation and
replace it with a new one which will be created from scratch to address
all the above issues.

This commit just cleans up the codebase so the new parser can be added
via a future PR.
2018-02-25 08:32:33 +00:00
Achilleas Anagnostopoulos
c09798622b acpi: provide more robust implementation for parsing AML method bodies
The previous implementation used brute-force approach where the parser
made an initial pass scanning the AML bytestream and looking for method
declaration opcodes. It then parsed out the method name and arg count
and populated a map which was used to detect the number of arguments to
be parsed upon encountering a method invocation. This approach proved to
be error-prone and would lead to an incorrect parse tree in the
following ASL example:

  Method (FOOF, 1, NotSerialized)
  {
    Return ("bar")
  }

  Method (TST0, 0, NotSerialized)
  {
    FOOF(0)
    \_SB.FOOF(2, 3)
  }

  Scope(\_SB){
    // Another FOOF method in \_SB which takes a different arg count
    Method (FOOF, 2, NotSerialized)
    {
      Return ("something")
    }
  }

In the above example the parser would correctly parse the first FOOF
call in TST0 but fail to parse the second invocation since the method
name contains a scope. The second invocation would actually yield the
following incorrect entity list (arguments appear as sibling entities):

Ref(\_SB.FOOF), Const(2), Const(3)

The new approach gets rid of the brute-force method and instead modifies
the initial parse of the tree not to parse the entities in the AML
method bodies but to instead track the start and end offset in the
AML stream for the body contents. In the second pass (where the parser
normally resolves symbol references), the parser can properly parse the
contents of method bodies since the entire AML tree is now known and the
parser can use the regular scope lookup rules to find the correct method
declaration for the invocation and figure out the argument count it
needs to parse.
2018-01-06 10:44:19 +00:00
Achilleas Anagnostopoulos
10ba4f7ad6 acpi: implement LazyRefResolver for entities that use lazy symbol references 2018-01-03 20:59:49 +00:00
Achilleas Anagnostopoulos
41eae61c9f acpi: update AML parser to use the new entities 2018-01-03 20:59:44 +00:00
Achilleas Anagnostopoulos
e7f203f06a acpi: move stream reader implementation into parser pkg 2018-01-03 20:55:37 +00:00
Achilleas Anagnostopoulos
d1eb0b6d4d acpi: move parser opcode table into the parser pkg 2018-01-03 20:55:37 +00:00
Achilleas Anagnostopoulos
7e419ae20e acpi: move entity visitor code to the entity pkg 2018-01-03 20:55:37 +00:00
Achilleas Anagnostopoulos
38143ab510 acpi: refactor scope lookup code and move it into the entity pkg 2018-01-03 20:55:37 +00:00
Achilleas Anagnostopoulos
17842763e9 acpi: move entities to the entity pkg, export them and add missing entities
This commit moves the AML entity definitions into the entity package and
makes them exportable so we can reference them from other packages.

In addition, the commit adds some missing entity structs that were
previously treated as generic entities (e.g. Processor, PowerResource
and ThermalZone).

Finally, this commit cleans the definitions and adds missing struct
attributes for the various field types (Field, IndexField, BankField)
2018-01-03 20:55:31 +00:00
Achilleas Anagnostopoulos
89923eb481 acpi: move AML opcode definitions into the entity pkg 2017-12-17 21:26:39 +00:00
Achilleas Anagnostopoulos
692155b44b acpi: refine post-parse entity processing rules
This commit updates the post-parse step so that:
- the visitor not longer recurses into method bodies. Since code inside
  methods may potentially generate dynamic/scoped entities or even use
  conditional invocations (if CondRefOf(X) { X(...) }), symbol resolution
  will be deferred to the AML interpreter.
- parent-child relationships between entities are checked and updated if
  not properly specified
2017-12-03 10:54:21 +00:00
Achilleas Anagnostopoulos
70c798f40a acpi: add pre-process step to capture arg counts for all function decls
Since the ACPI standard allows forward function declarations this step
is required so we can properly parse the argument list for function
invocations. Contrary to other AML entities, method invocations do not
include any sort of pkgLength information so unless we track the
expected argument count for each function, our parser will not be able
to figure out where the argument list ends.
2017-12-03 10:21:40 +00:00
Achilleas Anagnostopoulos
7983394390 acpi: implement resolver interface for methodInvocation entities 2017-12-03 10:17:41 +00:00
Achilleas Anagnostopoulos
0a05164703 acpi: change scopeVisit to visit entities in a visited entity's arglist 2017-12-01 08:01:17 +00:00
Achilleas Anagnostopoulos
d9bd6f104e acpi: fix linter warnings for unhandled errors in AML parser 2017-11-27 07:15:11 +00:00
Achilleas Anagnostopoulos
61a033e2ad acpi: tweak parser and add tests for parser errors 2017-09-30 16:40:53 +01:00
Achilleas Anagnostopoulos
d020045887 acpi: tag entities with the handle of the table that defines them
This allows us to implement the Unload opcode which given a handle,
removes all entities that are tagged by it.
2017-09-30 16:36:26 +01:00
Achilleas Anagnostopoulos
2a84c75d8e acpi: implement AML parser for all AML opcodes in the ACPI 6.2 spec 2017-09-30 16:36:22 +01:00
Achilleas Anagnostopoulos
4dd7c0b077 acpi: implement functions for working with AML scopes
The scope resolution rules are specified in page 252 of the ACPI 6.2
spec.
2017-09-30 16:25:34 +01:00
Achilleas Anagnostopoulos
130e11507c acpi: define structs for basic AML entities 2017-09-30 16:25:29 +01:00
Achilleas Anagnostopoulos
5171822ba6 acpi: define mappings and helpers for AML opcodes 2017-09-30 14:08:55 +01:00
Achilleas Anagnostopoulos
93125caa8a acpi: implement memory-based reader for AML byte-code streams 2017-09-30 13:45:30 +01:00
Achilleas Anagnostopoulos
7d959af0a9 acpi: import and register ACPI driver with hal 2017-08-28 07:28:31 +01:00
Achilleas Anagnostopoulos
78d5fac550 acpi: probe for RSDT and enumerate/map other ACPI tables (inc. DSDT) 2017-08-28 07:28:31 +01:00
Achilleas Anagnostopoulos
49dfc5c9de acpi: define structs for standard header and various ACPI tables 2017-08-28 07:28:27 +01:00
Achilleas Anagnostopoulos
7bcaf0ee8d vmm: implement identity mapping function for contiguous physical mem regions
vmm.IdentityMapRegion can be used by device drivers that want to
establish an identity mapping for a contiguous physical memory block in
order to access some hardware or table.
2017-08-28 07:28:04 +01:00
Achilleas Anagnostopoulos
0a271b206b pmm: implement FrameFromAddress
This is equivalent to vmm.PageFromAddress but returns back a pmm.Frame
2017-08-28 07:28:04 +01:00
Achilleas Anagnostopoulos
d17298acaa vga_text: Map EGA color indices to correct DAC entries for the VGA hw 2017-08-19 10:33:38 +01:00
Achilleas Anagnostopoulos
b53912757c Refactor hal code to use preferred driver detection order 2017-07-18 08:27:50 +01:00
Achilleas Anagnostopoulos
1ef27b3226 Update device drivers to use the device.RegisterDriver 2017-07-18 08:26:56 +01:00
Achilleas Anagnostopoulos
d180348116 Define DriverInfo and registration helpers 2017-07-18 08:23:43 +01:00
Achilleas Anagnostopoulos
37e32d9960 Provide correct implementation for cpu.FlushTLBEntry
The previous version worked under qemu (or qemu does not implement TLB
caching) but caused an unrecoverable page fault when running under
virtualbox.
2017-07-15 17:25:04 +01:00
Achilleas Anagnostopoulos
66d471f442 Defer kernel panic when Kmain returns 2017-07-14 08:05:59 +01:00
Achilleas Anagnostopoulos
ccba8877ce Enable support for deferred calls 2017-07-14 08:05:54 +01:00
Achilleas Anagnostopoulos
eaeae85600 Implement LogoSetter interface for vesa fb driver 2017-07-13 23:35:20 +01:00
Achilleas Anagnostopoulos
c7fc9f0ac9 Add gopher logos (64, 96 and 128 pixels tall)
The gopher images were obtained from: https://github.com/golang-samples/gopher-vector
2017-07-13 23:35:20 +01:00
Achilleas Anagnostopoulos
4af2ed62a0 Display the best-fit logo on logo-capable console devices
Logos can be disabled by passing the "consoleLogo=off" boot command line
parameter.
2017-07-13 23:35:20 +01:00
Achilleas Anagnostopoulos
cb7ae66556 Define LogoSetter interface and BestFit selection helper 2017-07-13 23:35:20 +01:00
Achilleas Anagnostopoulos
a5c6828fc2 Create tool for converting images to compatible console logo files
The tool processes an image and converts it to a logo.Image struct which
can be assigned to a logo-capable console.
2017-07-13 23:35:20 +01:00
Achilleas Anagnostopoulos
540f288e61 Select appropriate font for console devices with font support
The hal package automatically selects the best font from the list of
available fonts based on the console dimensions and the font priorities. The font
selection can be overriden by passing the "consoleFont" boot commandline
parameter to the kernel (e.g. consoleFont=terminus8x16)
2017-07-13 23:35:20 +01:00
Achilleas Anagnostopoulos
d71c4c1eea Add 8x16, 10x18 and 14x28 fonts based on the terminus font 2017-07-13 23:35:20 +01:00
Achilleas Anagnostopoulos
72feb11acb Document exported symbols 2017-07-13 23:35:20 +01:00
Achilleas Anagnostopoulos
f4f3745073 Extend vesa driver support to 15 and 16bpp framebuffers 2017-07-13 23:35:20 +01:00
Achilleas Anagnostopoulos
f02c767257 Extend vesa driver to support 24 and 32 bpp 2017-07-13 23:35:20 +01:00