Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

how to do scsi programming with hdd devices?



Hello,

i am new to MAC OS. I have to make a program that will
send inquiry, mode sense, mode select command to scsi
or fibre channel devices - hdd.

i have done some research, and this is where i am now.

I have the following data in the IO Registry(it's a
SCSI Flash Drive I have attached):

+-o IOSCSIParallelDevice@2<class IOSCSIParallelDevice>
{
"SCSI Product Name" = "XP39100S"
"SCSI Transfer Period" = 50000
"SCSI Transfer Width" = 1
"SCSI Target" = 2
"SCSI Transfer Offset" = 31
"SCSI Product Revision" = "LXQ0"
"SCSI Lun" = 0
"IOUserClientClass" = "IOSCSIUserClient"
"SCSI Vendor Name" = "QUANTUM"
"SCSI CmdQueue Enabled" = 0
"SCSI Device Type" = 0
"SCSI Transfer Options" = 0
"SCSI Removable Media" = No
"IOCFPlugInTypes" =
{"B4291228-0F0F-11D4-9126-0050E4C6426F"="IOSCSIParallelFamily.kex$
"IOUnit" = 2
}

+-oIOSCSIUserClientIniter<class
IOSCSIUserClientIniter>
{
"IOProviderClass" = "IOSCSIDevice"
"IOProviderMergeProperties" =
{"IOCFPlugInTypes"={"B4291228-0F0F-11D4-9126-0050E4C6$
"IOMatchCategory" = "IOSCSIUserClient"
"CFBundleIdentifier"= "com.apple.iokit.IOSCSIFamily"
"IOProbeScore" = 0
"IOClass" = "IOSCSIUserClientIniter"
}

+-o IOSCSIParallelInterfaceProtocolTransport <class
IOSCSIParallelInterfaceProtocolTrans$
{
"Power Management protected data" = "{
theNumberOfPowerStates =
2, version 1, power$
"IOMatchCategory" = "IODefaultMatchCategory"
"Physical Interconnect Location"="Internal/External"
"IOClass"="IOSCSIParallelInterfaceProtocolTransport"
"IOProviderClass" = "IOSCSIDevice"
"IOProbeScore" = 10000
"CFBundleIdentifier" =
"com.apple.iokit.IOSCSIParallelInterfaceProtocolTransport"
"Power Management private data" = "{ this object =
01e61600, interested driver = 01$
"Physical Interconnect" = "SCSI"
}

+-oIOSCSIPeripheralDeviceNub<class
IOSCSIPeripheralDeviceNub>
{
"Protocol Characteristics" = {"Physical Interconnect
Location"="Internal/External$
"IOMatchCategory" = "SCSITaskUserClientIniter"
"Product Identification" = "XP39100S"
"IOClass" = "IOSCSIPeripheralDeviceNub"
"IOProviderClass" = "IOSCSIProtocolServices"
"IOProbeScore" = 0
"Peripheral Device Type" = 0
"CFBundleIdentifier" =
"com.apple.iokit.IOSCSIArchitectureModelFamily"
"Vendor Identification" = "QUANTUM"
"Product Revision Level" = "LXQ0"
}

+-o IOSCSIPeripheralDeviceType00 <class
IOSCSIPeripheralDeviceType00>
{
"Power Management protected data" = "{
theNumberOfPowerStates = 5, version 1, p$
"IOMatchCategory" = "IODefaultMatchCategory"
"IOMaximumBlockCountWrite" = 256
"IOClass" = "IOSCSIPeripheralDeviceType00"
"IOMaximumBlockCountRead" = 256
"IOProviderClass" = "IOSCSIPeripheralDeviceNub"
"Peripheral Device Type" = 0
"IOProbeScore" = 5000
"CFBundleIdentifier" =
"com.apple.iokit.IOSCSIBlockCommandsDevice"
"Power Management private data" = "{ this object =
01e61000, interested driver $
}
+-oIOBlockStorageServices<class
IOBlockStorageServices>
{
"Protocol Characteristics" = {"Physical Interconnect
Location"="Internal/Exte$
"device-type" = "Generic"
"IOMaximumSegmentCountRead" = 32
"IOMaximumSegmentCountWrite" = 32
"Device Characteristics" = {"Product Revision
Level"="LXQ0","Vendor Name"="QU$
}
+-o IOBlockStorageDriver <class IOBlockStorageDriver>
{
"Statistics" = {"Bytes (Read)"=694784,"Latency Time
(Write)"=0,"Total Time $
"IOMatchCategory" = "IODefaultMatchCategory"
"IOClass" = "IOBlockStorageDriver"
"IOProviderClass" = "IOBlockStorageDevice"
"IOPropertyMatch" = {"device-type"="Generic"}
"IOProbeScore" = 0
"CFBundleIdentifier" =
"com.apple.iokit.IOStorageFamily"
"IOGeneralInterest" = ("_IOServiceInterestNotifier
is not serializable")
}
+-o QUANTUM XP39100S Media <class IOMedia>
{
"BSD Unit" = 2
"Content" = ""
"Whole" = Yes
"IOMediaIcon" =
{"IOBundleResourceFile"="Internal.icns","CFBundleIdentifi$
"Removable" = No
"Preferred Block Size" = 512
"Ejectable" = No
"Writable" = Yes
"Size" = 9104138240
"BSD Name" = "disk2"
"BSD Minor" = 20
"Content Hint" = ""
"BSD Major" = 14
"Leaf" = Yes
}
+-o IOMediaBSDClient <class IOMediaBSDClient>
{
"IOProbeScore" = 30000
"IOProviderClass" = "IOMedia"
"IOMatchCategory" = "IOMediaBSDClient"
"CFBundleIdentifier"=
"com.apple.iokit.IOStorageFamily"
"IOResourceMatch" = "IOBSD"
"IOClass" = "IOMediaBSDClient"
}

and I have the following snippet of the source code:
------------------------------------------------------int
main(){
kr = IOMasterPort(MACH_PORT_NULL, &masterPort);
if (kr || !masterPort){
printf("** ERROR: Couldn't create a master IOKit
Port(%08x)\n", kr);
return -1;
}

// Create the dictionaries
matchingDict = IOServiceMatching(kIOMediaClass);
kr = IOServiceGetMatchingServices(masterPort,
matchingDict, &iterator);
if (kr != KERN_SUCCESS){
printf("** ERROR: IOServiceGetMatchingServices:
failed. result = %d, iterator = %s\n",
kr, (iterator == NULL? "(NULL)": "NOT Null"));
return -1;
}

while ((service = IOIteratorNext(iterator)) &&
(service != NULL)){
// get the classname
kr = IOObjectGetClass(service, className);
if (kr == KERN_SUCCESS)
printf("ClassName = %s\n", className);
else
printf("** ERROR: failed to get className");

TestDevice(service);
kr = IOObjectRelease(service);
}

// Now done with the master port
mach_port_deallocate(mach_task_self(), masterPort);
}
void TestDevice(io_service_t service){
// Create the IOCFPlugIn interface for querying.
err = IOCreatePlugInInterfaceForService(service,
kIOSCSIUserClientTypeID, //plugin type
kIOCFPlugInInterfaceID, //interface type
&plugInInterface, //the interface
&score; //the score
if (err != noErr){
printf("IOCreatePlugInInterfaceForService returned
%03x\n", err);
return;
}
...
}

------------------------------------------------------My
questions are:

1.) Is it okay to just use the "matchingDict =
IOServiceMatching(kIOMediaClass);" to get a
dictionary of all harddisk attached? I will be
scanning for our company's device from that.

2.) Using the above code, when the device file is
requested for each "service" returned in
IOIteratorNext(), I get /dev/disk0, /dev/disk0s1,
...,
and so on. For the className, I get "IOMedia". Seems
I have already a dictionary of the device I wanted to
query. However, when executing
IOCreatePlugInInterfaceForService(), I always get
error, err = 0xe00002c7. Does 0xe00002c7 mean
"unsupported function"?
If yes, then which part of the code is wrong?

The final aim of this program is to send Inquiry, mode
sense, mode select scsi commands through CDB.
on MAC OS 10.2.8 and above.

3.) is there a sample short source code that will do
this? i tried to look on the sample source code on mac
site, i tried :
3.1) SCSIOldAndNew -
* New Method (STUC) - i tried using
peripheralDeviceType = 0x00.
I have one scsi hdd attached. but when i issue:
"IOServiceGetMatchingServices()" - i always
get iterator = NULL.
someone said this is because STUC is meant to
work only with devices other than 0x00, 0x05, 0x07,
0x0E.
* Old Method - the inquiry data can be retrieved
through the ioregistry, but when attempting to perform
"open" through an "interface", i get error "2c5"
device can't be opened. Is this normal for OSX 10.2.8?


(Am I on the right track?)

Thank you. It's a long mail. coz i want to be able to
give all details.
-Ana


__________________________________
Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
http://antispam.yahoo.com/whatsnewfree
_______________________________________________
darwin-drivers mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-drivers
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.