2009年9月14日 星期一

generate 32 or 64 bit binary by gcc

-m32
-m64

compile C program that calls Java

ex:
gcc -o test.o -I/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Headers -framework JavaVM test.c -m64

show file is 64 bit or 32 bits

ex:
file test.o

2009年9月9日 星期三

Quartz introduction

drawRect:
drawRect method of UIVew is called when a view needs to redraw itself
we usually add drawing code in this function

2009年9月6日 星期日

run terminal from applescript

use & to combine string

ex:
tell application "Terminal"
activate
repeat with i from 1 to 5
do script with command "cd test\\ " & i & ":ls"
set custom title of window 1 to "test" & i
end repeat
end tell

panic reporter

in Console's log files --> /Library/Logs --> PanicReporter

2009年8月26日 星期三

use ReleaseSCSITask to release SCSITaskIdentifier

because GetSCSITask will increase fNumCommandsOutstanding,
we must use this function to decrease fNumCommandsOutstanding

2009年8月21日 星期五

adjust aio queue length

sysctl -a | grep aio
find property about aio

sudo sysctl -w kern.aiomax=256

sudo sysctl -w kern.aioprocmax=256

sudo sysctl -w kern.aiothreads=256

for linux:
aio-max-nr

2009年8月4日 星期二

ftp command

mput *.js:
put every file that ends with .js

2009年7月9日 星期四

iostat

watch disk performance

ex:
iostat -w 1
display every second

2009年6月11日 星期四

kernel debug

type 14 = page fault
error code: 0: read from a non-present page
2: write to a non-present page

EIP: address of instruction at panic

create symbol file:
/Volumes/KernelDebugKit/createsymbolfiles -s /tmp PanicDriver/build/Debug/PanicDriver.kext

assume 0x223ab275 is EIP address
gdb /Volumes/KernelDebugKit/mach_kernel
--> set kext-symbol-file-path /tmp
--> add-kext ~/test.kext
--> set print asm-demangle on
--> x/i 0x223ab275
find the function mapped to this address
--> disass 0x223ab275
show this function's content
--> info line * 0x223ab275
show the line number of EIP in the function

2009年6月5日 星期五

vifs

edit /etc/fstab

set the disk not automount
UUID=5BFDB0C1-B240-3429-B9B0-20022AFBAA3C /test hfs rw,noauto

2009年6月3日 星期三

transfer visual project to xcode

1. new project -> Standard Tool

2. get visual project from cvs ( not get from visual stdio)

3. copy the files in visual project into this xcode project directory

4. set SCM Repository

2009年5月7日 星期四

driver terminate procedure

requestTerminate

terminate

willTerminate

didTerminate

detach

free

2009年5月3日 星期日

kernel core dump

configure server:
sudo mkdir /PanicDumps
sudo chown root:wheel /PanicDumps
sudo chmod 1777 /PanicDumps

sudo launchctl load -w /Sysytem/Library/LaunchDaemons/com.apple.kdumpd.plist

sudo launchctl list | grep kdump

configure client:
sudo nvram boot-args="debug=0xd44 _panicd_ip=10.10.1.1"
10.10.1.1 is server ip

2009年4月15日 星期三

2009年3月23日 星期一

unload module sequence

terminate --> stop --> free

2009年3月11日 星期三

driver dependency

set OSBundleCompatibleVersion & CFBundleVersion

set MODULE_VERSION the same as CFBundleVersion in xcode build

kextload -r /tmp test.kext
/tmp is where to find required kext

2009年3月9日 星期一

create jni in xcode

1.set "Header Search Paths"
/System/Library/Frameworks/JavaVM.framework/Headers

2. set "Executable Extensions"
jnilib

2009年2月28日 星期六

notebook 散熱

ELECOM 超冷卻 A4 冷台

2009年2月25日 星期三

2009年2月18日 星期三

important type for driver

IOReturn: IOKit/IOReturn.h

IOByteCount: IOKit/IOTypes.h

SCSITaskIdentifier: IOKit/scsi/SCSITask.h

IOBufferMemoryDescriptor: IOKit/IOBufferMemoryDescriptor.h

SCSI_Sense_Data: IOKit/scsi/SCSICmds_REQUEST_SENSE_Defs.h

UInt64: libkern/OSTypes.h

NULL: string.h

2009年2月10日 星期二

IO flow

AsyncReadWrite  -->  IssueRead  or IssueWrite

2009年2月8日 星期日

frequent include header in mac driver

string.h:   define NULL

IOKit/IOLib.h:   IOMalloc

2009年2月5日 星期四

IOMalloc

allocate memory in the driver

defined in  IOKit/IOLib.h


ioregistry

close it before unload driver because it may reference to the driver

2009年1月22日 星期四

define macro in xcode

ex:
configuration: Debug
gcc 4.0 processing-> preprocessor macros:   _DEBUG

combine c and c++ for apple driver

set build option:
gcc 4.0 language -->  compile source as -->  c++

2009年1月21日 星期三

info.plist for driver

IOMatchCategory:
set IODefaultMatchCategory to compare with other driver
the driver with higher probe score will win

2009年1月11日 星期日

IOLog

print message in the kernel

the message is stored at /var/log/system.log