Commit Graph

330 Commits

Author SHA1 Message Date
Connor Wood
fa24650ca7 Implemented opcodes 2017-07-08 10:20:33 +01:00
Connor Wood
59936e25e6 Implemented match 2017-07-07 11:39:08 +01:00
Connor Wood
00591235e1 Implemented further opcodes in full, added get to context 2017-07-07 10:37:09 +01:00
Connor Wood
980065d4d6 Fixed number of bugs 2017-07-05 14:36:40 +01:00
Connor Wood
def456a8e5 Added object modification 2017-07-03 11:11:07 +01:00
Connor Wood
50ac9d3abe Added a context manager 2017-07-03 10:31:01 +01:00
Connor Wood
590610f4a5 Refactored parser to execute in the parse step for efficiency and simplicity 2017-07-02 13:07:43 +01:00
Connor Wood
f72f97ef36 Rolled parsing and execution steps into one for namespace modifiers 2017-06-23 14:02:40 +01:00
Connor Wood
9fb15e7e92 Namespaces can now be concatenated, handling of SSDTs is now performed 2017-06-22 19:12:40 +01:00
Connor Wood
be1a75e472 Finalized ACPIType 2017-06-22 16:25:19 +01:00
Connor Wood
c83cefee08 Moved AccessType into namespace 2017-06-22 15:43:00 +01:00
Connor Wood
fb0e5137e8 Moved ConnectFieldBufferData to the namespace 2017-06-22 15:22:19 +01:00
Connor Wood
c8eca653b8 Moved ConnectFieldNameString into namespace 2017-06-22 15:09:04 +01:00
Connor Wood
0a67ad4b23 Moved DataRegion into namespace - more infrastructure required 2017-06-22 13:34:05 +01:00
Connor Wood
443c1ac1f8 Moved indexfield to namespace 2017-06-22 12:45:58 +01:00
Connor Wood
94e391c9b6 Moved arbitrary length buffer field into namespace 2017-06-22 12:23:14 +01:00
Connor Wood
cef562c832 Moved BufferFields into namespace 2017-06-22 12:16:30 +01:00
Connor Wood
12e7d1ad4d Moved BankField to the namespace 2017-06-22 12:02:17 +01:00
Connor Wood
2e64cea81f Removed temporary files 2017-06-21 20:54:29 +01:00
Connor Wood
312aff03c4 Moved Event to namespace 2017-06-21 20:50:08 +01:00
Connor Wood
19ccb3612b Moved Mutex to namespace 2017-06-21 20:27:46 +01:00
Connor Wood
fceba822eb Moved PowerResource into namespace 2017-06-21 20:13:44 +01:00
Connor Wood
636d94fd20 Moved Processor to namespace, and refactored namespace layout to use BTreeMap 2017-06-21 20:02:05 +01:00
Connor Wood
7095219316 Moved ComputationalData::String into namespace 2017-06-19 14:12:26 +01:00
Connor Wood
3ed94405aa Moved DefDevice and DefThermalZone to namespace 2017-06-19 13:49:37 +01:00
Connor Wood
190686a853 Moved Alias to the namespace 2017-06-19 13:33:20 +01:00
Jeremy Soller
cd67aabd5a Switch collections::boxed for alloc::boxed 2017-06-18 20:05:19 -06:00
Jeremy Soller
bbcd5197a4 Aml parser (#24)
* Initial parser proof of concept

* Added better error handling to the parser

* Refactored into a better directory structure

* Parse package length

* Implemented named string, scope op

* Properly bounds checked namestring

* Fixed namestring regressions

* Started work parsing DefRegionOp. NB: As TermArg is not yet implemented, a bug is present parsing the address offset and length. Additionally, a bug was fixed in NameString

* Completed DefOpRegion implementation. TermArg remains unimplemented, stubbed out

* Implemented TermArg parsing

* Implemented integer parts of computational data

* Implemented defField, and associated FieldList. FieldElement still remains stubbed

* Implmenented FieldElement

* Implmenented named field

* Parsed DefMethod

* Parsed ToHexString

* Parsed ToBuffer

* Parsed both subtract and sizeof

* Fixed size bug in sizeof parsing

* Parsed Store, fixed a parse bug where Target should be a SuperName not a TermArg

* Parsed while

* Parsed LLess

* Parsed DerefOf

* Parse Index

* Parse increment

* Parse device

* Parse device

* Parsed create dword field

* Parsed if/else block

* Properly parsed Target, rendered an AST from existing parse code, and stubbed out MethodInvocation parser method

* Implemented deferred loading, and deferred method invocation parses

* Parsed Or

* Fixed a bunch of off-by-one errors. Shows what I get for copying code around

* Parsed Return

* Fixed a boolean logic error in the handling of the extended instruction namespace

* Added DefBuffer to ComputationalData

* Removed a temporary file

* Parsed ReservedField

* Parsed DefPackage, DefAnd, and ComputationalData::String

* Parsed DefMutex

* Parsed DefAlias and RevisionOp

* Parsed DebugObj

* Parsed DefRefOf

* Parsed type 6 opcodes

* Added ObjectReference and DDBHandle to DataRefObj parsing

* Parsed DefVarPackage, in both Type2OpCode, and in DataObj

* Parsed DefBankField

* Parsed AccessField

* Parsed ConnectField

* Parsed CreateBitField

* Parsed CreateByteField

* Parsed CreateWordField

* Parsed CreateQWordField

* Parsed CreateField

* Parsed DefDataRegion

* Parsed DefEvent

* Parsed IndexField

* Parsed DefPowerRes

* Parsed DefProcessor

* Parsed DefThermalZone:

* Parsed ExtendedAccessField

* Parsed DefBreak, DefBreakPoint, DefContinue and DefNoop (all type 1 opcodes with no parameters and one byte)

* Parsed DefFatal

* Parsed DefLoad

* Parsed DefNotify

* Parsed DefRelease

* Parsed DefReset

* Parsed DefSignal

* Parsed DefSleep

* Parsed DefStall

* Parsed DefUnload

* Parsed DefAcquire

* Parsed DefAnd

* Parsed DefConcat

* Parsed ConcatRes

* Switched Concat and ConcatRes opcodes

* Parsed CondRefOf

* Parsed DefDecrement and DefCopyObject

* Parsed DefDivide, fixed length calculation bug in a bunch of parse routines

* Parsed DefFindSetLeftBit

* Parsed DefFindSetRightBit

* Parsed DefFromBCD

* Parsed DefLAnd

* Parsed DefLGreater

* Parsed LNot

* Parsed DefLOr

* Parsed DefLoadTable

* Parsed DefMatch

* Parsed DefMid

* Parsed DefMod

* Parsed DefMultiply

* Parsed DefNAnd

* Parsed DefNOr

* Parsed DefNot

* Parsed DefObjectType

* Parsed DefShiftLeft and DefShiftRight

* Parsed DefTimer

* Parsed DefToBCD, DefToDecimalString, DefToInteger and DefToString

* Parsed DefXor

* Parsed DefWait

* Implemented a parser, abstract syntax tree, and basic infrastructure for the AML subsystem of the ACPI module. The entire AML grammar is parsed and placed into an abstract syntax tree, with one exception: method invocations, rather than parsing, defer the load until later on in the process, due to the way the grammar works.

Still to be done:
 - Refactor the code: a lot of the parser is very repetitive, and could easily be refactored with the aid of macros. This would reduce the length and improve legibility, though not affect function.
 - More rigorous testing of parser: the parser has, thus far, only been tested on the DSDT in QEMU. There may be bugs present that are hidden.
 - Parse the SSDTs: the SSDTs should be parsed after the DSDT, and contain more AML bytecode to be treated as modifying the same namespace. Adding this would be simple, though not urgent.
 - Transform the AST into a concrete executable tree: the CET is what will hold all information necessary to execute control methods and evaluate namespace objects. While this could be done in the AST, due to the way AML is laid out this would be very inefficient and require a lot of repetitive transformations every time something is to be executed. Therefore, perform the transformations upfront.
 - Parse the deferred loads, and the method invocations contained within: Once the AST has been rendered into a CET, sufficient information will be present to parse method invocations and add those to the namespace.
 - Bytecode interpreter: Once the CET has been finalized with method invocation parsing, it can then be called and executed.
 - Control method executor: this should walk the namespace, locating the relevant control method, then calling the interpreter on it.
 - Namespace enumerator: the executor shall use this to walk the namespace, and it should also be publicly accessible to allow outside code to determine what devices are present in the system.
 - Memory accessor API: ACPI AML has a concept of memory access in certain device domains - for example, the PCI BAR registers. These are all device specific offsets, therefore device drivers, or more accurately bus drivers, should be capable of installing handlers to manage this memory access.
 - CET concatenation: The DSDT and SSDTs all affect the same namespace, therefore concatenating the resulting trees should be possible.
 - Type checking: some operations in AML are typed. This should be handled at tree transformation time or earlier, and could indeed done in the parse step with some modification to the parser. This is currently not the case.

* Initial parser proof of concept

* Added better error handling to the parser

* Refactored into a better directory structure

* Parse package length

* Implemented named string, scope op

* Properly bounds checked namestring

* Fixed namestring regressions

* Started work parsing DefRegionOp. NB: As TermArg is not yet implemented, a bug is present parsing the address offset and length. Additionally, a bug was fixed in NameString

* Completed DefOpRegion implementation. TermArg remains unimplemented, stubbed out

* Implemented TermArg parsing

* Implemented integer parts of computational data

* Implemented defField, and associated FieldList. FieldElement still remains stubbed

* Implmenented FieldElement

* Implmenented named field

* Parsed DefMethod

* Parsed ToHexString

* Parsed ToBuffer

* Parsed both subtract and sizeof

* Fixed size bug in sizeof parsing

* Parsed Store, fixed a parse bug where Target should be a SuperName not a TermArg

* Parsed while

* Parsed LLess

* Parsed DerefOf

* Parse Index

* Parse increment

* Parse device

* Parse device

* Parsed create dword field

* Parsed if/else block

* Properly parsed Target, rendered an AST from existing parse code, and stubbed out MethodInvocation parser method

* Implemented deferred loading, and deferred method invocation parses

* Parsed Or

* Fixed a bunch of off-by-one errors. Shows what I get for copying code around

* Parsed Return

* Fixed a boolean logic error in the handling of the extended instruction namespace

* Added DefBuffer to ComputationalData

* Removed a temporary file

* Parsed ReservedField

* Parsed DefPackage, DefAnd, and ComputationalData::String

* Parsed DefMutex

* Parsed DefAlias and RevisionOp

* Parsed DebugObj

* Parsed DefRefOf

* Parsed type 6 opcodes

* Added ObjectReference and DDBHandle to DataRefObj parsing

* Parsed DefVarPackage, in both Type2OpCode, and in DataObj

* Parsed DefBankField

* Parsed AccessField

* Parsed ConnectField

* Parsed CreateBitField

* Parsed CreateByteField

* Parsed CreateWordField

* Parsed CreateQWordField

* Parsed CreateField

* Parsed DefDataRegion

* Parsed DefEvent

* Parsed IndexField

* Parsed DefPowerRes

* Parsed DefProcessor

* Parsed DefThermalZone:

* Parsed ExtendedAccessField

* Parsed DefBreak, DefBreakPoint, DefContinue and DefNoop (all type 1 opcodes with no parameters and one byte)

* Parsed DefFatal

* Parsed DefLoad

* Parsed DefNotify

* Parsed DefRelease

* Parsed DefReset

* Parsed DefSignal

* Parsed DefSleep

* Parsed DefStall

* Parsed DefUnload

* Parsed DefAcquire

* Parsed DefAnd

* Parsed DefConcat

* Parsed ConcatRes

* Switched Concat and ConcatRes opcodes

* Parsed CondRefOf

* Parsed DefDecrement and DefCopyObject

* Parsed DefDivide, fixed length calculation bug in a bunch of parse routines

* Parsed DefFindSetLeftBit

* Parsed DefFindSetRightBit

* Parsed DefFromBCD

* Parsed DefLAnd

* Parsed DefLGreater

* Parsed LNot

* Parsed DefLOr

* Parsed DefLoadTable

* Parsed DefMatch

* Parsed DefMid

* Parsed DefMod

* Parsed DefMultiply

* Parsed DefNAnd

* Parsed DefNOr

* Parsed DefNot

* Parsed DefObjectType

* Parsed DefShiftLeft and DefShiftRight

* Parsed DefTimer

* Parsed DefToBCD, DefToDecimalString, DefToInteger and DefToString

* Parsed DefXor

* Parsed DefWait

* Implemented a parser, abstract syntax tree, and basic infrastructure for the AML subsystem of the ACPI module. The entire AML grammar is parsed and placed into an abstract syntax tree, with one exception: method invocations, rather than parsing, defer the load until later on in the process, due to the way the grammar works.

Still to be done:
 - Refactor the code: a lot of the parser is very repetitive, and could easily be refactored with the aid of macros. This would reduce the length and improve legibility, though not affect function.
 - More rigorous testing of parser: the parser has, thus far, only been tested on the DSDT in QEMU. There may be bugs present that are hidden.
 - Parse the SSDTs: the SSDTs should be parsed after the DSDT, and contain more AML bytecode to be treated as modifying the same namespace. Adding this would be simple, though not urgent.
 - Transform the AST into a concrete executable tree: the CET is what will hold all information necessary to execute control methods and evaluate namespace objects. While this could be done in the AST, due to the way AML is laid out this would be very inefficient and require a lot of repetitive transformations every time something is to be executed. Therefore, perform the transformations upfront.
 - Parse the deferred loads, and the method invocations contained within: Once the AST has been rendered into a CET, sufficient information will be present to parse method invocations and add those to the namespace.
 - Bytecode interpreter: Once the CET has been finalized with method invocation parsing, it can then be called and executed.
 - Control method executor: this should walk the namespace, locating the relevant control method, then calling the interpreter on it.
 - Namespace enumerator: the executor shall use this to walk the namespace, and it should also be publicly accessible to allow outside code to determine what devices are present in the system.
 - Memory accessor API: ACPI AML has a concept of memory access in certain device domains - for example, the PCI BAR registers. These are all device specific offsets, therefore device drivers, or more accurately bus drivers, should be capable of installing handlers to manage this memory access.
 - CET concatenation: The DSDT and SSDTs all affect the same namespace, therefore concatenating the resulting trees should be possible.
 - Type checking: some operations in AML are typed. This should be handled at tree transformation time or earlier, and could indeed done in the parse step with some modification to the parser. This is currently not the case.

* Partial refactor of AML code

* Further refactoring

* Fully refactored type 2 opcode selector

* Refactored type 6 opcode selector

* Further refactored Type 2 opcode parsing

* Implemented basic infrastructure in order to render the AST down to a namespace object

* Resolved scopes into the namespace

* Put OpRegion into namespace

* Rendered field parsing to the namespace object

* Methods now placed in namespace

* Moved DefName into the namespace

* Moved packages into the namespace

* Converted shutdown sequence to use AML parser

* Moved shutdown over to use AML parsing fully

* Removed the no longer needed DSDT code

* Better messages on unmapping failure

* Disable preemption until paging bug is fixed

* Refactor kernel mapping so that symbol table is mapped

* Add symbol lookup (still very WIP)

* Improve method of getting symbol name

* Reenable preemption

* Demangle symbols

* Fix overallocation

* Remove tilde files
2017-06-17 18:47:27 -06:00
Jeremy Soller
73a71a7d85 Increase size of kernel heap when live disk is loaded 2017-06-17 14:32:31 -06:00
Jeremy Soller
85c02365c9 Fix overallocation 2017-06-14 20:26:05 -06:00
Jeremy Soller
c9cbdab9f1 Demangle symbols 2017-06-14 20:25:49 -06:00
Jeremy Soller
7ef2401db3 Reenable preemption 2017-06-14 20:25:38 -06:00
Jeremy Soller
9b19ab9439 Improve method of getting symbol name 2017-06-13 21:56:20 -06:00
Jeremy Soller
acab23d1e1 Add symbol lookup (still very WIP) 2017-06-13 21:43:37 -06:00
Jeremy Soller
d6354aeb56 Refactor kernel mapping so that symbol table is mapped 2017-06-13 20:42:04 -06:00
Jeremy Soller
8b05863ebb Disable preemption until paging bug is fixed 2017-06-13 19:10:32 -06:00
Jeremy Soller
e3020db04f Better messages on unmapping failure 2017-06-11 08:40:27 -06:00
Jeremy Soller
8d89925842 Align ELF segments to avoid subtract overflow 2017-06-04 18:34:45 -06:00
Jeremy Soller
138463b74a Merge pull request #21 from ids1024/unique
Update for changes in std::ptr::Unique API
2017-06-02 20:56:01 -06:00
Ian Douglas Scott
3c5b262b0e Update for changes in std::ptr::Unique API 2017-05-21 13:44:10 -07:00
Jeremy Soller
4d2808a012 Remove free count print 2017-05-12 21:04:52 -06:00
Jeremy Soller
32b0c06314 Remove hardcoded live filesystem 2017-05-11 21:16:07 -06:00
Jeremy Soller
62d3f4bd93 Add Xargo support 2017-05-10 21:38:40 -06:00
Jeremy Soller
b3a25bd3a3 Merge pull request #14 from bjorn3/ls_root_scheme
Ls root scheme
2017-04-29 06:49:55 -06:00
Jeremy Soller
d8630faccb Merge pull request #15 from bjorn3/remove_pit_ticks_assert
Remove PIT_TICKS assert
2017-04-29 06:40:28 -06:00
bjorn3
248cfa51ae Remove PIT_TICKS assert 2017-04-29 10:46:07 +02:00
bjorn3
ca8b6f522e Fix closing ls handle 2017-04-29 10:43:50 +02:00
bjorn3
8ffe704e7a Remove yet another unnecessary change 2017-04-28 18:44:37 +02:00
bjorn3
4441b750cf Remove unnecessary change 2017-04-28 18:43:39 +02:00
bjorn3
c9fdc4beae Make it working 2017-04-28 18:42:33 +02:00