Friday, August 15, 2008

AppleACPIBatteryManager for Tiger and Leopard

Hi guys,

Here is the beta AppleACPIBatteryManager I have been working on. It will work with original PowerManagement and you don't need AppleACPIPowerSource. Although some values may have "0" value, it should display "Time" and "Percentage" but I am not sue if it is accurate or not. Also, "Power source" should detect correctly and icon should change correctly. If you are using the notebook, you can give it a try.

It is based on original AppleSmartBatteryManager and linux driver. It should work both on Tiger and Leopard. (I used Tiger to compile the source code and it work on my 10.4.11 and 10.5.4)

Again, it is just the beta version and you probably need the original PowerManagement with it. Make sure that you don't have AppleACPIPowerSource Installed or it will cause error.

Chun-Nan

=====
Battery Information:

Model Information:
Serial Number: TOSHIBA-PA3399U -Li-Ion-3658Q
Manufacturer: TOSHIBA
Device name: PA3399U
Pack Lot Code: 0000
PCB Lot Code: 0000
Firmware Version: 0000
Hardware Revision: 0000
Cell Revision: 0000
Charge Information:
Charge remaining (mAh): 4400
Fully charged: Yes
Charging: No
Full charge capacity (mAh): 4400
Health Information:
Cycle count: 1
Condition: Good
Battery Installed: Yes
Amperage (mA): 0
Voltage (mV): 11100

=====
Update: 7/6/2008
1. Using "fCurrentVoltage" to FAKE "fCurrentRate" if "fCurrentRate" is read as 0.

UPDATE: 7/7/2008
1. Using "fMaxCapacity" to FAKE "fCurrentRate" if "fCurrentRate" is read as 0.
2. Change battery dectection funcion. (battery inserted and removed)
2. Change poll time from 10 seconds to 30 seconds

UPDATE: 7/9/2008
1. Make sure "fMaxCapacity" is always equal to or larger than "fCurrentCapacity".

UPDATE: 7/10/2008
1. Added "Battery Information" and "Battery Status" so that it will show on ioreg.
2. Using "fMaxCapacity" to caculate remaning time while battery is charging.

UPDATE: 7/11/2008
1. Cleaned up some unused codes.
2. Tried to fix the percentage issue.

UPDATE: 7/13/2008
1. Serial Number will show type and serial number instead of 0 if it reads any data.
2. Tried to fix more than one battery bay issue by using "_UID" flag. (need feedbacks)

UPDATE: 7/21/2008
1. Tried to fix OSString/OSData issue on battery info. (need feedbacks)
2. Tried to fix more than one battery bay issue. (need feedbacks)

UPDATE: 7/21/2008
1. Tried to fix more than one battery bay issue by using "_STA" flag. (need feedbacks)

UPDATE: 7/26/2008
1. Added CycleCount caculation and CellVoltages information. (need feedbacks)
2. Added "SMBIOS Informaiton" table for MaxErr, SerialNumber, and ManufactureDate. (need feedbacks)

UPDATE: 7/29/2008
1. Using "fCurrentVoltage" to caculate temperature.
( [fCurrentVoltage * fCurrentRate] should be used to caculate temperature. However, when the battery is FULL, fCurrentRate will be 0 and will make temperature become 0. To make it simpe, just use fCurrentVoltage untill I find a better solution.)
2. Fixed wrong "Power Unit" issue.

UPDATE: 7/29/2008
1. Changed [class AppleACPIBattery] to [class AppleACPIBatteryDevice]. Hopefully, it will fix the random KP due to the duplicated class AppleACPIBattery while ApplePowerSource is also installed at the same time.
2. Tried to fix more than one battery bay issue by using "numBatteriesSupported()" first. When the returned value is more than 1, it will check "_STA" flag. Otherwise, it will skip the "_STA" flag check. Also, rewrote the "_STA" flag check function. (need feedbacks from those who has more than one battery bay in the notebook.)

UPDATE: 8/11/2008
1. Removed "_UID" flag and related function.
2. Improved battery inserted/removed detection function.
3. Set "fUnitFactor" to 1 if it is read/caculated as 0. (Make sure denominator is not 0)
4. Moved "setExternalChargeCapable" function from "setBatteryBIF" to "setBatteryBST" rountine.
5. Reset "fAverageRate" to 0 when the state of battery changes.

(Now it will show "Calculating" first, then "Time" later, while plugging in or pulling out the AC power, like my MacBook does. tongue.gif )

UPDATE: 8/15/2008
1. Fixed long "Calculating" problem.

UPDATE: 10/25/2008
1. Fixed the problem that battery meter doesn't show 100% after finished charging.
2. Changed to only read last three bit for "fCurrentRate" in case that the value read from ACPI table is too big.

Wednesday, July 09, 2008

AppleACPIPS2Nub for Leopard only

Hi guys,

Here is the beta AppleACPIPS2Nub I have revised. It will work with any version of AppleACPIPlatform without editing the info.plist. Hopefully, in the future, we don't have to worry about AppleACPIPlatform being updated and losing the PS/2 devices.

It is based on original dfe's ACPIPS2Nub. (http://www.tgwbd.org/darwin/extensions.html) I have tested it with 1.1.0 and 1.2.1 of AppleACPIPlatform and it works. Make sure that you don't have ACPIPS2Nub Installed or it will cause error.

Again, it is just the beta version and backup the original ACPIPS2Nub before trying it.

Update: 7/9/2008
1. Cleaned up.

Update: 7/23/2008, 8/2/2008
1. AppleACPIPS2Nub_b5: Fixed PS/2 keyboard working without PS/2 mouse existed in the system.
2. AppleACPIPS2Nub_Mouse: Fixed PS/2 mouse working without PS/2 keyboard existed in the system.

AppleACPIPS2Nub_Mouse is basically the same as AppleACPIPS2Nub_b5. In the AppleACPIPS2Nub_b5, mouse is attached to keyboard while in the AppleACPIPS2Nub_Mouse, keyboard is attached to mouse.

(You might need the modified ApplePS2Controller to make your PS/2 devices work if your system ONLY has PS/2 keyboard OR PS/2 mouse existed.)

Wednesday, July 02, 2008

AppleSMBIOSEFI for Tiger and Leopard

Hi guys,

Here is the beta AppleSMBIOSEFI I have been working on. It will work with original AppleSMBIOS but will try to fix or add some values that original AppleSMBIOS misses. Therefore, you don't have to worry about AppleSMBIOS being updated.

It is based on original AppleSMBIOS and it only works with EFI system right now. It is for both Tiger and Leopard. In addiation, it should fix "About This Mac" crash problem and wrong "Bus Speed" issue.

You can change the memory speed. Just boot with "memorySpeed=n" (n is the speed number you want)
You can change the memory type. Just boot with "memoryType=n" (n is the type number you want, 18 is DDR, 19 is DDR2)

Example:
memoryType=19 memorySpeed=533

Again, it is just the beta version and you still need the original AppleSMBIOS with it.

Chun-Nan

==============================
static const char *
SMBMemoryDeviceTypes[] =
{
"RAM", /* 00h Undefined */
"RAM", /* 01h Other */
"RAM", /* 02h Unknown */
"DRAM", /* 03h DRAM */
"EDRAM", /* 04h EDRAM */
"VRAM", /* 05h VRAM */
"SRAM", /* 06h SRAM */
"RAM", /* 07h RAM */
"ROM", /* 08h ROM */
"FLASH", /* 09h FLASH */
"EEPROM", /* 0Ah EEPROM */
"FEPROM", /* 0Bh FEPROM */
"EPROM", /* 0Ch EPROM */
"CDRAM", /* 0Dh CDRAM */
"3DRAM", /* 0Eh 3DRAM */
"SDRAM", /* 0Fh SDRAM */
"SGRAM", /* 10h SGRAM */
"RDRAM", /* 11h RDRAM */
"DDR SDRAM", /* 12h DDR */
"DDR2 SDRAM", /* 13h DDR2 */
"DDR2 FB-DIMM" /* 14h DDR2 FB-DIMM */
};
==============================

Update: 5/6/2008
1. It will use value of "cpu->externalClock" first. If that value returns 0, it will use value of "FSBFrequency".
2. Add "FSB" flag. You can change the FSB value in case the value is still not correct. Just boot with "FSB=n" (n is the speed number you want) However, it doesn't update the value back to "FSBFrequency" yet.

Update: 7/2/2008
1. based on AppleSMBIOS-28
2. Added "serial-number", "board-id", and "system-type". The default serial-number is "W1234567890".
3. Released AppleSMBIOSEFI from memory after adding the values.
4. It should work both on Tiger and Leopard. (I used Tiger to compile the source code.)

Sunday, May 25, 2008

CardBus/PCMCIA PC Cards for Leopard

Hello,

Here is the IOPCCardFamily file that I have worked on today. I complied the source files offered from Apple and also fixed some bugs. You do not have to edit the info.plist to match your machine. If your pccard shows "IOPCCardBridge::start failed", you can give it a try.

How to use?
  • Backup your original IOPCCardFamily driver (and IOPCIFamily driver)
  • Replace your IOPCCardFamily driver (and IOPCIFamily driver) with the attached one that contains all necessary modifications
  • Reboot
  • As root, type "dmesg | grep PC"; you should see something being found
Welcome to try it. Don't forget to backup the old files before trying it.

CardBus/PCMCIA PC Cards for Tiger

Hello,

Here is the IOPCCardFamily file that I have worked on today. I complied the source files offered from Apple and also fixed some bugs. You do not have to edit the info.plist to match your machine. If your pccard shows "IOPCCardBridge::start failed", you can give it a try.

How to use?
  • Backup your original IOPCCardFamily driver (and IOPCIFamily driver)
  • Replace your IOPCCardFamily driver (and IOPCIFamily driver) with the attached one that contains all necessary modifications
  • Reboot
  • As root, type "dmesg | grep PC"; you should see something being found
Welcome to try it. Don't forget to backup the old files before trying it.