- Joined
- Jan 18, 2013
- Messages
- 271
- Motherboard
- Mac mini
- CPU
- i[5/7]
- Graphics
- HD[3/4]000
- Mac
- Classic Mac
- Mobile Phone
Part I
I want to share something with you. I've seen people copying lines from Apple ACPI tables into their own tables. Probably without even knowing what it does, and in some cases it is pointless. Have a look at this code snippet:
You may find one or more of them in your EHCn methods, but again. Having them is pointless, because Arg0 isn't matching with the given UUID (in the buffer) on OS X. In short. This whole stupid block can be removed.
I also see people using stuff like this:
Why? Why check OSDW when you are in fact running OS X and your DSDT/SSDT will only be used for OS X? I don't get it. To me that is pointless. All you need is this one-liner:
Much cleaner without all clutter. Don't you agree? In short. Do not check for something that you already know. Let's have a look at another great example.
Ah yes. You need to have this method. Right? Nope. You don't. Not to mention that this method will check all sixteen bytes of the UUID (in the buffer) twice. Which of course slows down the startup process.
Let's stop this madness. Stop living in the 90's. Use something like this when you need to set device properties from ACPI tables:
Another example of clutter free/faster ACPI code.
Don't forget this important rule folks. We're not Apple. They want to support Window, Linux and OS X. We don't. Or at least I don't
Oh yes. There is a lot more that we can change, but not today. Taking things one step at a time.
I want to share something with you. I've seen people copying lines from Apple ACPI tables into their own tables. Probably without even knowing what it does, and in some cases it is pointless. Have a look at this code snippet:
Code:
[FONT=Menlo]
[/FONT][FONT=Menlo]Alias (SBV1, SDGV)
[/FONT][FONT=Menlo]Method (_DSM, 4, Serialized)[/FONT]
[FONT=Menlo]{[/FONT]
[FONT=Menlo] If (LEqual (Arg0, Buffer (0x10)[/FONT]
[FONT=Menlo] {[/FONT]
[FONT=Menlo] /* 0000 */ 0x8F, 0x70, 0xFC, 0xA5, 0x75, 0x87, 0xA6, 0x4B, [/FONT]
[FONT=Menlo] /* 0008 */ 0xBD, 0x0C, 0xBA, 0x90, 0xA1, 0xEC, 0x72, 0xF8[/FONT]
[FONT=Menlo] }))[/FONT]
[FONT=Menlo] {[/FONT]
[FONT=Menlo] Name (_T_0, Zero)[/FONT]
[FONT=Menlo] Store (ToInteger (Arg2), _T_0)[/FONT]
[FONT=Menlo] If (LEqual (_T_0, Zero))[/FONT]
[FONT=Menlo] {[/FONT]
[FONT=Menlo] If (LEqual (Arg1, One))[/FONT]
[FONT=Menlo] {[/FONT]
[FONT=Menlo] Return (Buffer (One)[/FONT]
[FONT=Menlo] {[/FONT]
[FONT=Menlo] 0x07[/FONT]
[FONT=Menlo] })[/FONT]
[FONT=Menlo] }[/FONT]
[FONT=Menlo] Else[/FONT]
[FONT=Menlo] {[/FONT]
[FONT=Menlo] Return (Buffer (One)[/FONT]
[FONT=Menlo] {[/FONT]
[FONT=Menlo] 0x00[/FONT]
[FONT=Menlo] })[/FONT]
[FONT=Menlo] }[/FONT]
[FONT=Menlo] }[/FONT]
[FONT=Menlo] Else[/FONT]
[FONT=Menlo] {[/FONT]
[FONT=Menlo] If (LEqual (_T_0, One))[/FONT]
[FONT=Menlo] {[/FONT]
[FONT=Menlo] If (LEqual (SDGV, 0xFF))[/FONT]
[FONT=Menlo] {[/FONT]
[FONT=Menlo] Return (Zero)[/FONT]
[FONT=Menlo] }[/FONT]
[FONT=Menlo] Else[/FONT]
[FONT=Menlo] {[/FONT]
[FONT=Menlo] Return (One)[/FONT]
[FONT=Menlo] }[/FONT]
[FONT=Menlo] }[/FONT]
[FONT=Menlo] Else[/FONT]
[FONT=Menlo] {[/FONT]
[FONT=Menlo] If (LEqual (_T_0, 0x02))[/FONT]
[FONT=Menlo] {[/FONT]
[FONT=Menlo] Return (SDGV)[/FONT]
[FONT=Menlo] }[/FONT]
[FONT=Menlo] }[/FONT]
[FONT=Menlo] }[/FONT]
[FONT=Menlo] }[/FONT]
[FONT=Menlo]
[/FONT]
[FONT=Menlo] Return (Zero)[/FONT]
[FONT=Menlo]}[/FONT]
I also see people using stuff like this:
Code:
[FONT=Menlo]Method (_PRW, 0, NotSerialized)[/FONT]
[FONT=Menlo]{[/FONT]
[FONT=Menlo] If (OSDW)[/FONT]
[FONT=Menlo] {[/FONT]
[FONT=Menlo] Return (Package (0x02)[/FONT]
[FONT=Menlo] {[/FONT]
[FONT=Menlo] 0x0D, [/FONT]
[FONT=Menlo] 0x04[/FONT]
[FONT=Menlo] })[/FONT]
[FONT=Menlo] }[/FONT]
[FONT=Menlo] Else[/FONT]
[FONT=Menlo] {[/FONT]
[FONT=Menlo] Return (Package (0x02)[/FONT]
[FONT=Menlo] {[/FONT]
[FONT=Menlo] 0x0D, [/FONT]
[FONT=Menlo] 0x03[/FONT]
[FONT=Menlo] })[/FONT]
[FONT=Menlo] }[/FONT]
[FONT=Menlo]}[/FONT]
Code:
[FONT=Menlo]Name (_PRW, Package (0x02) { 0x0D, 0x04 })[/FONT]
Code:
[FONT=Menlo]Method (DTGP, 5, NotSerialized)
{
If (LEqual (Arg0, Buffer (0x10)
{
/* 0000 */ 0xC6, 0xB7, 0xB5, 0xA0, 0x18, 0x13, 0x1C, 0x44,
/* 0008 */ 0xB0, 0xC9, 0xFE, 0x69, 0x5E, 0xAF, 0x94, 0x9B
}))
{
If (LEqual (Arg1, One))
{
If (LEqual (Arg2, Zero))
{
Store (Buffer (0x01)
{
0x03
}, Arg4)
Return (One)
}
If (LEqual (Arg2, One))
{
Return (One)
}
}
}
Store (Buffer (0x01)
{
0x00
}, Arg4)
Return (Zero)
}
[/FONT]
Let's stop this madness. Stop living in the 90's. Use something like this when you need to set device properties from ACPI tables:
Code:
Device (EHCn)
{
Name (AAPL, Package (0x0B)
{
"AAPL,current-available",
0x0834,
"AAPL,current-extra",
0x0898,
"AAPL,current-extra-in-sleep",
0x0640,
"AAPL,max-port-current-in-sleep",
0x0834,
"AAPL,device-internal",
0x02,
Buffer (One) { 0x00 }
})
Method (_DSM, 4, NotSerialized)
{
If (LEqual (Arg2, Zero))
{
Return (Buffer (One) { 0x03 })
}
Return (RefOf (AAPL))
}
Don't forget this important rule folks. We're not Apple. They want to support Window, Linux and OS X. We don't. Or at least I don't
Oh yes. There is a lot more that we can change, but not today. Taking things one step at a time.