Summary: C programming language / query for hardware attributes q uestion.

From: Farmer, John (John.Farmer_at_TycoHealthcare.com)
Date: 04/14/05

  • Next message: Padiyath Sreekumaran: "MPI and PVM"
    Date: Thu, 14 Apr 2005 10:47:29 -0400
    To: Tru64-UNIX-Managers@ornl.gov
    
    

    Thanks to all who contributed. Below is the original question and following
    that are the various contributions(with credit to their authors cited) that
    I received in response.

    Original Question:
    > Tru64 5.1A and/or 5.1B.
    >
    > # hwmgr -view devices -cat disk
    > HWID: Device Name Mfg Model Location
    >
    >
    ----------------------------------------------------------------------------
    > --
    > 123: /dev/disk/dsk1c COMPAQ HSV110 (C)COMPAQ IDENTIFIER=11
    >
    > # hwmgr -get attributes -a dev_base_name=dsk1 -a phys_location
    > 123:
    > dev_base_name = dsk1
    > phys_location = IDENTIFIER=11
    >
    > Above are two samples of the use of the hwmgr utility to query a system to
    > determine the 'location' (i.e. IDENTIFIER=11) associated with a specific
    > device base name. I am currently writing a program in 'C' for which I
    need
    > a function which will programmatically obtain the above information.
    >
    > Loose Pseudo-code example of what I am looking for:
    >
    > struct hw_structure_definition *a
    > a=some_routine_to_query_system_for_hw_info("dsk1")
    > printf("%s\n",a->phys_location)
    >
    > Please note the above is pseudo-code - the text does not represent actual
    > structure names, variable names or function names. I suspect that the
    > functions I need are in existence but not documented in the normal man
    pages
    > (perhaps in the "Writing Device Drivers" manual?? which I do not have a
    copy
    > of for 5.1x stream)
    >
    > Over the phone HP support has indicated that they think it is going to
    > involve some combination of the use of the table() function and the
    ioctl()
    > function. They are getting back to me on the specifics and I am
    diligently
    > reading through the man pages and querying my friends on tru64 managers
    list
    > in the meanwhile.
    >
    > Searching around the /usr/include/io/cam directory I found some
    interesting
    > function names that might relate to what I am looking for but without an
    > associated man page I cannot be sure. Example: cam3.h
    > xpt_get_phys_attribute().
    >
    > If anyone knows a function/routine and its associated calling standard
    that
    > would achieve the above I would be very appreciative.
    >
    > John Farmer, Senior Systems Programmer
    > Tyco Healthcare/US Surgical
    > 150 Glover Ave
    > Norwalk, CT 06856
    >
    Contributions:-

    Thanks to Doctor Thomas Blinn (as always!), Thomas Cunningham, Tom Linden,
    and Bluejay Adametz for their contributions to my question. The summary is
    as follows:

    Dr. Blinn informed me that the the table() and ioctl() functions were not
    what I was looking for. Instead, he advised that 1) The routines I would
    need are actually a part of the hardware management subsystem library
    routines. 2) The routines are particularly messy to use and that I would
    have a bear of a time figuring them out unless I had examples (such as hwmgr
    which calls them directly but alas, the sources are not available for
    customer review). 3) Although not elegant I might be better off using the
    system() function to pass it a hwmgr command and then parse the output. Dr.
    Blinn has answered several of my questions in the past and has never lead me
    wrong. It will be quite the prize if I can ever prove him incorrect or
    mistaken on a technical topic!! I'm not holding my breath though.

    Thomas Cunningham provided me with links to HP online documentation incuding
    the manual titled writing device drivers. He provided me with an additional
    set of links pointing to various device i/o functions. I am still digesting
    the information on these pages but they are certainly a good read for anyone
    working directly with hardware devices. The links are:

    http://h30097.www3.hp.com/docs/dev_doc/DOCUMENTATION/HTML/DDK_R2/DOCS/HTML/M
    AN/INDEXES/INDEX_D.HTM

    http://h30097.www3.hp.com/docs/pub_page/doc_list.html

    Bluejay Adametz suggested the same as Dr. Blinn that I make a call to the
    hwmgr command and parse the output.

    Tom Linden suggested that I use take a look at the getsysinfo() function.
    Quite a good function with many useful applications but it did not have the
    pieces of info I was looking for. He was also generous enough to provide a
    program titled tiptoe.c which returned various pieces of information
    regarding the hardware hierarchy.

    An HP support person over the phone told me that he had a book with an
    example of what I wanted to do but that he didn't have a soft copy to
    provide me with. Additionally the relevant information was occupying more
    than 50 pages so it was too much to fax. The title of this document is:
    Writing Device Drivers for the SCSI/CAM Architecture Interfaces with a Part
    Number of AA-PS3GD-TE. This book is apparently different from the "Writing
    Device Drivers" book that I referenced above in the contribution from Tom
    Cunningham.

    Again, thanks to everyone who contributed.

    John
    Today must be Thursday. I never could get the hang of Thursdays...
    --Arthur Dent - character from "The Hitchhikers Guide to the Galaxy"


  • Next message: Padiyath Sreekumaran: "MPI and PVM"

    Relevant Pages

    • Re: Unsafe USB Memory stick removal
      ... I don't think I was being clear with the original question. ... Tray app that provides the safe method of "Eject or unplug hardware". ... discussion is based on the kernal side of writing device drivers. ... > The "Unsafe Removal of Device" was removed from Windows XP entirely. ...
      (microsoft.public.development.device.drivers)
    • Re: GPL vs BSD Licence
      ... The whole SCO vs IBM mess is an illustration of just how goofy the entire ... IBM claims that they have standing to sue over LINUX because they've ... But since contributions are derivative works, ... I think device drivers and modules are different. ...
      (freebsd-questions)
    • Return to Original Question
      ... Jeff & MikeD: ... Guys thanks for your contributions so far. ... the original question with the requested clarifications. ...
      (microsoft.public.vb.general.discussion)