这两天在网上查了下,找到一些有用的资料.首先是这个:ftp://ftp.software.ibm.com/pc/pccbbs/mobiles_pdf/aps2mst.pdf
这是IBM官方关于APS的白皮书.介绍的很详细,包括APS程序包主要文件及其功能.
ShockPrf.sys: kernel mode device driver for prediction algorithm and hard disk drive control   Shockmgr.sys: kernel mode driver for miscellaneous operation
Sensor.dll: application interface dll
TpShCPL.cpl: control applet
TpShocks.exe: task tray application
TpShCPL.dll: bitmap resource file for this application program
TpShPrm.hta: promotion pop-up window
TpShPrm.gif: animation for promotion pop-up window
TpShPrm.jpg: banner picture for promotion pop-up window

其中最主要的就是前三个.而两个sys文件是驱动文件,第三个DLL文件是封装给程序使用的库.
用eXeScope 查看Sensor.dll export的函数:
Ordinal         Address         Name
00000001     10001960     ShockproofCallSMAPIBIOS
00000002     10001310     ShockproofControl
00000003     100018D0     ShockproofEnableDisableSnooze
00000004     100015E0     ShockproofGetAccelerometerData
00000005     10001640     ShockproofGetAccelerometerDataEx
00000006     10001560     ShockproofGetAccelerometerMutex
00000007     100012B0     ShockproofGetAutoDisable
00000008     100014F0     ShockproofGetShockStatus
00000009     10001500     ShockproofGetSlaveCPUinfo
0000000A     10001480     ShockproofGetUnloadCnt
0000000B     10001360     ShockproofGetVersion
0000000C     10001B30     ShockproofInformMouseDevChange
0000000D     100019C0     ShockproofInformPENevent
0000000E     100016A0     ShockproofInformPMevent
0000000F     10001A20     ShockproofInformTabletLIDstate
00000010     10001810     ShockproofInvokeSnooze
00000011     10001780     ShockproofManualSensitivitySetting
00000012     100015B0     ShockproofReleaseAccelerometerMutex
00000013     10001270     ShockproofSetAutoDisable
00000014     10001840     ShockproofSnoozeSetting
00000015     100016D0     ShockproofTaskComplete

在众多函数中最有价值的莫过于
ShockproofGetAccelerometerData这个函数.它可以得出传感器输出的数据.输出数据的结构如下:
typedef struct _ACCELREPORT {
          INT       PresentState;         // Current internal state (stable: 0, unstable1: 1: unstable2: 2)
          USHORT    LatestRawAccelDataX; // latest raw acceleration data of X axis     <-- works!
          USHORT    LatestRawAccelDataY; // latest raw acceleration data of Y axis     <-- works!
          USHORT    LatestAccelDataX;     // latest acceleration data of X axis (average in 40ms)    <-- Works even better?
          USHORT    LatestAccelDataY;     // latest acceleration data of Y axis (average in 40ms)    <-- Works even better?
          CHAR      Temperature;          // latest temperature
          USHORT    LatestZeroG_X;        // latest zero-G offset of X axis   <-- Seems to be the current notion of "center"
          USHORT    LatestZeroG_Y;        // latest zero-G offset of Y axis   <-- ""
      } ACCELREPORT;

数据的实际意义我还有搞清楚,但是感觉不像是个加速度传感器输出的数值,更像是个陀螺仪之类.是一个X,Y坐标.利用这个函数就可以做一些有意思的事情.比如配合windows API :LockWorkStation()就可以做个机器锁定并防盗的程序.

另外还找到一片英文的短文:
IBM ThinkPad Accelerometer, aka "Active Protection System"

Announced in November 2003;   Probably shipped in 2004 March

Analog Devices Inc (ADI) make the sensor and boast about it in their Press Releases

Probably an ADXL311 originally and now switched to ADXL320 since the first is getting deprecated.

These eat 3 volts at about 400 micro-amps and give 2 analogue outputs back, X and Y.

At rest in the horizontal plane these will both be measuring 1g .

Falling is more than than this, rising is less than this.

Tilt is collected as gavity decreases in a sin() as the chip is tilted through 90^ degrees.

Still puzzled about *where* the values are being read in from

Initial assumption was a chip on the I2C/SMBUS.   But since it's a 2-channel a-to-d, could be anyway
---eg, existing fan monitoring chip.

Windows drivers read in 28-bytes via an IOCTL(0x733fc) on "\ShockMgr" .   (See shockprf.sys)

Apple is shipping a 2-axis sensor in new PowerBooks.   Acccessed via the smbus.
dead easy since we have (some) info.

Referred to as "Sudden Motion Sensor".   and "Mobile Motion Module".   and "Apple Motion Sensor"
uni-n@f8000000/i2c@f8001000/i2c-bus@1/accelerometer@b0
pci@f2000000/mac-io@17/gpio@50/accelerometer-1@13
pci@f2000000/mac-io@17/gpio@50/accelerometer-2@14

Compaq has a sensor in some of their Tablet PCs to tell which way the display is rotated/pointing (Also ADI)

Windows Driver:
===============

From:
   ftp://ftp.software.ibm.com/pc/pccbbs/mobiles_pdf/aps2mst.pdf

     The active protection system employs a heuristic learning algorithm to track
   system orientation. The Shock Manager, a system thread created by the
   Shockprf.sys of a kernel mode device driver,
analyzes the variations in acceleration
   and collects system orientation data into the Shock History Database. The collected
   data is then used to tune sensitivity and predict excessive shocks. This tuning is
   important in minimizing the disk performance penalty caused by prediction
   failures. Once the Shock Manager detects a certain variation which may be
   equivalent to one usually seen just before receiving an excessive shock, the Shock
   Manager acts immediately to stop the hard disk drive
.

The writes to 0xed are just to the ("non-existant") delay port.

The other two ports are super-I/O controller/IDE ports and I think the
write is to stop the drive and then stop the IDE Bus.
还没有细看,空了再说,睡觉了,大家晚安.




blog comments powered by Disqus

Published

2006-12-04

Categories


Tags