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

248 Commits

Author SHA1 Message Date
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
3396b997e7
Merge pull request #61 from achilleasa/refactor-aml-parser-into-multiple-packages
Refactor AML parser into multiple packages and fix parser bugs
2018-01-06 10:53:44 +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
61597cff56
Merge pull request #60 from achilleasa/improve-handling-of-fwd-decls-in-aml-parser
Improve handling of forward declarations in AML parser
2017-12-03 11:14:48 +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
61449a15a1 lint: enable check for proper handling of return values 2017-11-22 07:03:56 +00:00
Achilleas Anagnostopoulos
4aa2600b65 Merge pull request #59 from achilleasa/place-linter-deps-in-build-folder
Prepend build folder to GOPATH before building/testing/linting
2017-10-25 07:43:05 +01:00
Achilleas Anagnostopoulos
11baa1e8f5 Prepend build folder to GOPATH before building/testing/linting 2017-10-25 07:33:24 +01:00
Achilleas Anagnostopoulos
0f85d4be53 Merge pull request #53 from achilleasa/implement-aml-parser
Implement AML parser
2017-09-30 16:44:09 +01: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
4e985c91c6 Merge pull request #56 from achilleasa/update-vagrantfile
vagrantfile: include gcc and binutils in the list of installed packages
2017-09-24 10:12:48 +01:00
Achilleas Anagnostopoulos
41d245d331 vagrantfile: include gcc and binutils in the list of installed packages 2017-09-24 10:06:35 +01:00
Achilleas Anagnostopoulos
52be87b67f Merge pull request #54 from dvrkps/patch-1
travis: update go version
2017-09-19 19:08:46 +01:00
Davor Kapsa
04a097bf4f travis: update go version 2017-09-18 09:45:41 +02:00
Achilleas Anagnostopoulos
14aef16459 Merge pull request #52 from achilleasa/detect-acpi-support-and-enumerate-acpi-tables
Detect ACPI support and enumerate ACPI tables
2017-08-28 07:49:00 +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
324022187d Merge pull request #51 from achilleasa/fix-vga-text-palette-mapping
Map EGA color indices to correct DAC entries for VGA HW
2017-08-19 11:07:28 +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
08c845a9ac Use the correct CI env name 2017-08-08 23:57:54 +01:00
Achilleas Anagnostopoulos
9838f468a7 Fix minor typo in BUILD.md 2017-08-08 23:42:25 +01:00
Achilleas Anagnostopoulos
301024eb89 Merge pull request #49 from achilleasa/improve-readme
Improve documentation
2017-08-08 23:38:27 +01:00
Achilleas Anagnostopoulos
b5bd7da046 Update readme 2017-08-08 23:34:24 +01:00
Achilleas Anagnostopoulos
63e9f40d47 Add build guide 2017-08-08 23:34:19 +01:00
Achilleas Anagnostopoulos
c778693de0 Merge pull request #48 from achilleasa/vbox-make-target
Add Makefile target for running gopher-os ISO using vbox
2017-08-08 23:24:15 +01:00
Achilleas Anagnostopoulos
cb0f7312cf Add vbox run target to the Makefile and rename run target to run-qemu 2017-08-08 23:11:59 +01:00
Achilleas Anagnostopoulos
2549dc9837 Add contributing and status markdown files 2017-08-08 22:56:58 +01:00
Achilleas Anagnostopoulos
4b25971cef Merge pull request #47 from achilleasa/order-based-driver-probing
Order based driver detection/loading
2017-07-18 08:37:58 +01:00
Achilleas Anagnostopoulos
b53912757c Refactor hal code to use preferred driver detection order 2017-07-18 08:27:50 +01:00