Commit Graph

355 Commits

Author SHA1 Message Date
Connor Wood 94b0e7de37 Moved Event to namespace 2017-07-15 10:14:51 +01:00
Connor Wood 9575c6fed3 Moved Mutex to namespace 2017-07-15 10:14:51 +01:00
Connor Wood e52d4c98a3 Moved PowerResource into namespace 2017-07-15 10:14:51 +01:00
Connor Wood b4ddaeadbb Moved Processor to namespace, and refactored namespace layout to use BTreeMap 2017-07-15 10:14:50 +01:00
Connor Wood 73562b3f56 Moved ComputationalData::String into namespace 2017-07-15 10:14:01 +01:00
Connor Wood c58aa38247 Moved DefDevice and DefThermalZone to namespace 2017-07-15 10:14:01 +01:00
Connor Wood 07cf7385e9 Moved Alias to the namespace 2017-07-15 10:14:01 +01:00
Jeremy Soller 1085fa3838 Merge pull request #38 from ids1024/espipe
Make seek on pipe return ESPIPE
2017-07-14 17:15:31 -06:00
Ian Douglas Scott 89f695dd28 Make seek on pipe return ESPIPE 2017-07-14 15:58:24 -07:00
Jeremy Soller ff9f2322a6 Merge pull request #37 from ids1024/cloexec
Make dup/dup2 clear cloexec
2017-07-14 12:56:28 -06:00
Ian Douglas Scott 09a4980442 Make dup/dup2 clear cloexec 2017-07-14 08:48:42 -07:00
Jeremy Soller 30385fec48 Merge pull request #36 from CWood1/hpet
HPET Driver
2017-07-14 08:32:52 -06:00
Connor Wood 0b6bde7c68 Moved PIT driver into kernel 2017-07-14 15:26:04 +01:00
Connor Wood 0bd6f11a4f Implemented HPET driver 2017-07-14 13:58:06 +01:00
Connor Wood 0cbdb2d0c0 Saved HPET table for global access 2017-07-14 10:39:50 +01:00
Connor Wood 387cd41e5e Implemented ACPI table 2017-07-14 10:36:27 +01:00
Jeremy Soller 56ba795845 Merge pull request #34 from ids1024/dup2
Make dup2() work if second file descriptor doesn't exist
2017-07-13 15:55:16 -06:00
Ian Douglas Scott 6f081f4bbd Make dup2() work if second file descriptor doesn't exist 2017-07-13 14:43:55 -07:00
Jeremy Soller 2c0cc3a8a1 Merge pull request #33 from ids1024/path
Pass relative, not canonicalized, path to script
2017-07-13 09:49:59 -06:00
Ian Douglas Scott f020fe2ac5 Pass relative, not canonicalized, path to script 2017-07-13 08:09:36 -07:00
Jeremy Soller 6981f0cd36 Merge pull request #32 from ids1024/process
Strip whitspaces after #!
2017-07-13 07:11:39 -06:00
Ian Douglas Scott b5da98396e Strip whitspaces after #!
Autotools configure scripts seem to use "#! /bin/sh"
2017-07-12 23:03:53 -07:00
Jeremy Soller 687f991ab4 Merge pull request #31 from ids1024/fstat
Implement fstat() for pipe scheme
2017-07-12 07:05:46 -06:00
Ian Douglas Scott f81a276536 Implement fstat() for pipe scheme 2017-07-11 21:26:35 -07:00
Jeremy Soller a03457a9eb Simpler debug message 2017-07-10 20:33:29 -06:00
Jeremy Soller a3493d16fd Allow simple signal delivery to PID 1 (the kernel idle process) 2017-07-10 20:28:10 -06:00
Jeremy Soller 268ba3ece7 Remove syscall replacement 2017-07-10 20:13:01 -06:00
Jeremy Soller a0b06a2835 Merge branch 'master' of https://github.com/redox-os/kernel 2017-07-10 20:09:01 -06:00
Jeremy Soller ab738cede5 Restore kernel parameters on sigreturn 2017-07-10 20:08:57 -06:00
Jeremy Soller 8f6268eef7 Merge pull request #30 from ids1024/pipe
Revert "pipe: make read() return when write end is closed"
2017-07-10 17:10:16 -06:00
Ian Douglas Scott 79a45a2580 Revert "pipe: make read() return when write end is closed"
This reverts commit 09a67641c6.
2017-07-10 11:15:45 -07:00
Jeremy Soller b5ff0aabd5 WIP: Signal handling 2017-07-09 21:34:38 -06:00
Jeremy Soller 7e52541f39 Implement passthrough of futimens 2017-07-09 15:43:26 -06:00
Jeremy Soller 3f40af0687 Update to new allocator API 2017-07-08 19:50:58 -06:00
Jeremy Soller 22e87d94d4 Merge pull request #29 from ids1024/pipe
pipe: make read() return when write end is closed
2017-07-08 06:56:36 -06:00
Ian Douglas Scott 09a67641c6 pipe: make read() return when write end is closed 2017-07-07 21:05:38 -07:00
Jeremy Soller ae5a32cf98 Merge pull request #28 from ids1024/dup
Pass empty second argument to dup in exec
2017-07-06 18:29:07 -06:00
Ian Douglas Scott 074ce2e57d Pass empty second argument to dup in exec 2017-07-06 16:44:54 -07:00
Jeremy Soller d0c3a5d2aa Merge pull request #27 from ids1024/clone
Pass empty second argument to dup() call in clone
2017-07-06 05:54:59 -06:00
Ian Douglas Scott b2df8d676f Pass empty second argument to dup() call in clone
I don't know if this was there for a reason, but it was making the dup()
fail with tcpd, and I don't seem this being handled specially in redoxfs
or anywhere else.
2017-07-05 22:45:27 -07:00
Jeremy Soller d4e295a385 Revert syscall path 2017-07-05 21:46:40 -06:00
Jeremy Soller 0e8e1b5c4e WIP: Signal handling 2017-07-05 21:45:53 -06:00
Jeremy Soller a4c3afb446 Merge pull request #26 from ids1024/getppid
Implement getppid system call
2017-06-29 06:34:49 -06:00
Ian Douglas Scott dddd87c2c3 Implement getppid system call 2017-06-28 22:05:01 -07:00
Jeremy Soller 12d487ec9c Merge pull request #19 from bjorn3/fix_warnings
Fix most lint warnings, check multicore code even if disabled
2017-06-26 06:52:50 -06:00
bjorn3 2dcd563709 Merge branch 'master' into fix_warnings 2017-06-26 14:22:17 +02:00
Jeremy Soller 0478e5f7fb Merge pull request #25 from ids1024/env
Make env: return ENOENT on non-existent; support unlink()
2017-06-20 17:06:13 -06:00
Ian Douglas Scott b9f659dadf Make env: return ENOENT on non-existent; support unlink() 2017-06-20 15:56:44 -07: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