搜尋此網誌
2015年2月10日 星期二
如果你的無線鍵盤與滑鼠不能連接上你的iMac時,該如何處理?
當你的iMac已經過保固,你又不想資付龐大維修費(6000~7000塊)去送修。你可以去買一支Bluetooth USB裝置(400塊左右)接上iMac,這樣你的無線鍵盤與滑鼠右可以使用了。
MacBook Air與MacBook Pro可以偵測的到Bluetooth USB裝置,但無線鍵盤與滑鼠還是連不上。但iMac可以使用此裝置,並可以偵測的到無線鍵盤與滑鼠。
試試看吧! 省省荷包。
2014年2月13日 星期四
How to backup(restore) Mac OS image to a hard disk?
- Get a Thunderbolt SATA controller device, and attach a hard disk. Connect the Thunderbolt cable to your Mac Book.
- Turn ON the Power with the Mac Book, and Press the "Option" Key. That will show boot device menu.
- Choose the "Disk Utility" Item.
- And then erase the HDD.
- You can rename it or use the default name.
- confirm the erasing step.
- Restore item is for backup the Mac OS to a free Hard Disk.
- Start to restore.
- Clear all data.
- Remaining time will be showing up.

- Completed and reboot the system. Then press the "Option" Key and choose the backup HDD, verify whether it can be booting up.
- Check the name of the booting HDD.
2013年1月25日 星期五
在Mac下,如何進入UEFI模式
在Mac平台下的UEFI並不是一個圖形管理的介面,一般是只有一個命令列,如:Shell〉。開機時,透過的組合鍵或是熱鍵來進入功能設定介面。一般來說不太需要修改設定,因為它本身就是最佳化設置。
你可以在Mac開機時,按住如下的組合鍵,去進入其功能設定:
你可以在Mac開機時,按住如下的組合鍵,去進入其功能設定:
- 按住
〈C〉,從CD 或DVD 光碟機啟動,如:Mac OS X 安裝光碟。 - 按住〈D〉
,如果插入安裝DVD 1,則啟動為Apple Hardware Test (AHT)。 - 按住〈Option〉+〈Command〉+〈PR〉 ,直到聽到兩聲BB聲-->Reset NVRAM。
- 按住〈Option〉 ,開機後進入Startup Manager,你可以在這些選項中,選擇從一個你想的Mac OS X 項目去開機。注意:按住〈N〉 鍵,可顯示出第一個可啟動的網絡選項。你也可以選擇從UEFI磁碟作開機,去做一些內部設定。
- 按住〈Eject〉or〈F12〉 ,或者按住鼠標鍵(/觸控板),退出所有可移動的媒體,如光碟,USB。
- 按住
〈N〉,試著從相容的網絡伺服器(NetBoot)去作開機的動作。 - 按住
〈T〉,開機後成為FireWire 目標(Taget)的磁碟模式。 - 按住
〈Shift〉,開機後成為安全模式,並且暫時關閉登錄選項。 - 按住〈Command〉+
〈V〉,開機後成為Verbose 模式。 - 按住〈Command〉+〈S〉,開機後成為單一使用者模式。
- 按住〈Option〉+〈N〉,使用系統預設執的開機鏡像,從NetBoot伺服器開機。
2012年8月30日 星期四
判斷Mac如何被叫醒?
此文章從下列鏈結翻譯而來:
Determine Why Your Mac Wakes Up From Sleep
你曾經把你的MAC做睡眠(sleep),當您返回到本機時,才發現它似乎是被它自己所喚醒? 我已經碰到這個奇怪的問題好幾次了,與幾個終端命令可以幫助你去追查是什麼原因造成Mac從睡眠狀態被喚醒。
啟動終端機,然後輸入下面指令在命令列:
syslog |grep -i "Wake reason"
接下來你將會看到一份列表從系統日誌,那看起來如下:
Sat May 10 08:49:33 MacBookPro kernel[0] : Wake reason = OHC1
Sat May 11 17:21:57 MacBookPro kernel[0] : Wake reason = PWRB
Sun May 15 08:34:20 MacBookPro kernel[0] : Wake reason = EHC2
Sun May 20 18:25:28 MacBookPro kernel[0] : Wake reason = OHC1
現在你會想看“Wake reason=”旁邊文字的代碼。那麼這些喚醒原因的代碼是什麼意思?
OHC:開放式主機控制器支援,通常是USB或Firewire。如果你看到OHC1或OHC2,它幾乎可以確定是一個外接USB鍵盤或鼠標來喚醒此機器。
EHC:增強型主機控制器支援,是另一個USB介面,但也能夠是無線(wireless)與藍牙(bluetooth)設備,因為它們也是裝在Mac的USB匯流排上。
USB:一個USB裝置喚醒此機器。
LID0:這就是你的MacBook或Pro的蓋子,當你開啟蓋子時,機器將從睡眠中喚醒。
PWRB:代表的是電源按鈕,在你的Mac上,這個是物理電源按鈕。
RTC:即時計時器警報信號,一般而言是喚醒需求(wake-on-demand)的服務,像是當你安排睡眠與喚醒,經由在Mac上的節能控制面板。它也可以是啟動設定,使用者應用程式,備份,和其他預定的事件。
那裡可能有一些其他的代碼(例如:PCI,GEGE,等等。),但在上面是大部分的人將看見在系統日誌中。一旦你找到了這些代碼,你可以縮小範圍到底是什麼原因造成你的Mac從睡眠被喚醒,表面上看來是任意地。
注意:您還可以監視這喚醒的原因代碼經由控制台來觀察,如果你不習慣的命令行上操作。然而,在我過去的經驗裡,搜索和使用控制台是比終端機慢的。這通常是因為系統預設的字符串在控制台上比對搜索,它將通過所有你的系統與應用程式日誌,包括那些來自第三方的。
2012年4月17日 星期二
How to design a Mac drivers? --(2)
Create
a new project in Xcode
Add project from “IOKit Driver” template
Modify
the plist
This file likes the Inf of window drivers. Then
add HBA information.
To add the libraries
Loading
kernel extension at boot time
If the driver would like to support
booting, that need add into “Local-Root”
Implement
[driver entry]
No support virtual memory, only physical
memory. So driver can use it to prepare task directly.
• Inherit from class IOSCSIParallelInterfaceController
• InitializeController / StartController
– driver_init / driver_probe_one
• TerminateController / StopController [unload driver]
– driver_exit / driver_detach_one
• ReportInitiatorIdentifier
– (struct Scsi_Host *)->unique_id
• ReportHighestSupportedDeviceID [Max
Device ID]
– (struct Scsi_Host *)->max_id - 1
• ReportMaximumTaskCount
– (struct Scsi_Host *)-> can_queue
• ReportHBAHighestLogicalUnitNumber [Max LUN]
– (struct Scsi_Host *)->max_lun - 1
• ReportHBASpecificTaskDataSize [Resource
size per Request]
• ReportHBASpecificDeviceDataSize [Resource
size per Device]
• DoesHBAPerformDeviceManagement [Scan
every device behind HBA, driver has to
add/remove single device by itself]
• DoesHBASupportSCSIParallelFeature
• ProcessParallelTask [driver_queue_command]
• FilterInterruptRequest / HandleInterruptRequest [driver_isr_handler]
• InitializeTargetForID =>[No
Supported]
Implement
in second step
• AbortTaskRequest
• AbortTaskSetRequest
• ClearACARequest
• ClearTaskSetRequest
• LogicalUnitResetRequest
• TargetResetRequest
• HandleTimeout (Optional)
• ReportHBAConstraints (Optional)
=> [to support 64bits need handle this function]
• InitializeDMASpecification (Optional)
OS X
kernel / Linux functions
table
Linux
|
OS X
|
printk
|
IOLog
|
pci_iomap
|
mapDeviceMemoryWithIndex
|
pci_iounmap
|
(IOMemoryMap
*)->release
|
pci_set_master
|
setBusMasterEnable
|
pci_set_dma_mask
|
initWithSpecification
|
kzalloc
|
IOMalloc
|
kfree
|
IOFree
|
INIT_LIST_HEAD
|
queue_init
|
list_add_tail
|
queue_enter
|
list_for_each_entry
|
queue_iterate
|
list_del
|
queue_remove
|
list_empty
|
queue_empty
|
list_first_entry
|
queue_first
|
scsi_sg_count
|
(IODMACommand
*)->fNumSegments
|
scsi_sglist
|
(IODMACommand
*)->gen64IOVMSegments
|
scsi_bufflen
|
GetRequestedDataTransferCount
|
sg_dma_address
|
GetDMACommand
|
cpu_to_le32
|
OSSwapHostToLittleConstInt32
|
pci_alloc_consistent
|
IOMallocContiguous
|
pci_free_consistent
|
IOFreeContiguous
|
pci_map_sg
|
(IODMACommand
*)->prepare
|
pci_unmap_sg
|
(IODMACommand
*)->complete
|
ioread32
|
ioRead32
|
iowrite32
|
ioWrite32
|
udelay
|
IODelay
|
msleep
|
IOSleep
|
spin_lock_irqsave
|
IOLockLock
|
spin_unlock_irqrestore
|
IOLockUnlock
|
do_gettimeofday
|
clock_get_calendar_microtime
|
scsi_add_device
|
CreateTargetForID
|
scsi_remove_device
|
DestroyTargetForID
|
scsi_device_lookup
|
GetTargetForID
|
pci_write_config_dword
|
configWrite32
|
virt_to_phys
|
(IOMemoryDescriptor
*)->getPhysicalAddress
|
(struct
scsi_cmnd *)->scsi_done
|
CompleteParallelTask
|
SAM_STAT_GOOD
|
kSCSITaskStatus_GOOD
|
SAM_STAT_CHECK_CONDITION
|
kSCSITaskStatus_CHECK_CONDITION
|
INQUIRY
|
kSCSICmd_INQUIRY
|
Support
device PNP
• IOSCSIParallelInterfaceController::DoesHBAPerformDeviceManagement()
– [return false]: made the handle of OS discover if that has any attached devices
been attaching.
– [return true]: driver needs to have a mechanism for detecting, adding and
removing devices.
• Create a thread in IOSCSIParallelInterfaceController::StartController()
to scan device from id 0 to (max target id -1 ) with INQUIRY command.
• Create a thread when get a bus change doorbell and scan all devices
again.
• If INQUIRY command status is GOOD: use CreateTargetForID() to add
device.
• ELSE use DestroyTargetForID() to remove device.
Register
power management for status change
• Driver MUST initialize power management; otherwise system can’t go
sleep successful.
–
PMinit();
–
joinPMtree();
–
registerPowerDriver();
• Implement IOSCSIParallelInterfaceController::setPowerState()
–
driver will receive a
notification when system get an event change for “SLEEP” or “WAKEUP”.
–
Implement IOSCSIParallelInterfaceController::systemWillShutdown
()
–
driver will receive a
notification when system get “RESTART” and “POWEROFF”.
Support 32bit/64bit kernel
• Build settings:
– Architectures: Standard (32/64-bit Intel)
– Build Active Architecture Only: No
• Starting up with the 32-bit or 64-bit kernel
– Method 1: Startup key combination
•
64-bit: holding the 6 and 4
keys during startup.
•
32-bit: holding the 3 and 2
keys during startup.
– Method 2: On-disk setting (persistent)
•
sudo systemsetup -setkernelbootarchitecture
x86_64
•
sudo systemsetup -setkernelbootarchitecture
i386
Virtual
Device for application
How to
do verification
• Load/Unload command:
– sudo cp –r mvumi.kext /tmp/mvumi.kext
– sudo kextload /tmp/mvumi.kext
– sudo kextunload /tmp/mvumi.kext
• Test tools
– rwfile
– AJA System Test
– Blackmagic Disk Speed Test
Boot
OS X from third-party HBA
• Mac OS X don’t provide a official method to insert driver during OS
installation.
• But we can “CLONE” a existing OS X to HBA and boot
from it.
– 1. Install driver to /System/Library/Extensions/
– 2. Restart OS and holding “option” key during startup
– 3. Select “Recovery HD” to boot
– 4. Open a terminal and load driver from:
/Volumes/Macintosh
HD/System/Library/Extensions
– 5. Open “Disk utility”, use “Restore” to clone original disk to HBA.
Build
driver package
• Change the “Build Configuration” to “Release” before release the
driver package.
• Create a pkg file with “PackageMaker”
– If you didn’t find it in disk, you can download “Auxiliary tools for
xcode” from Apple Developer Site.
• Create a dmg file with command
hdiutil create test.dmg -srcfolder test.pkg
• Enjoy!!
訂閱:
文章 (Atom)


