APLawrence - Information and Resources for Unix and Linux Systems, Bloggers and the self-employed
RSS Feeds Get APLawrence.com by RSS











(OLDER) <- More Stuff -> (NEWER) (NEWEST)
Home > News Posts > dual ported ram device driver virtual memory physical memory ––>Re: KERNEL PANIC when my Device Driver accesses hardware
Printer Friendly Version




News Group Posts

dual ported ram device driver virtual memory

physical memory


From: robertl@localhost.localdomain (Robert Lipe)
Subject: Re: KERNEL PANIC when my Device Driver accesses hardware
References: <3c2eb8eb.29083668@news.bigpond.com> 
Date: Sun, 30 Dec 2001 14:01:10 GMT

[ followup-to set to c.u.s.p.]

On Sun, 30 Dec 2001, Bob Morrison <rmorrison1@bigpond.com.au> wrote:



>I have run into a brick wall while attempting to write a device driver
>to access a hardware adaptor which uses a 1k block of dual port ram
>located at address 0x0CA000.

It can be done.

>I have determined, using printf statements, that the driver is
>receiving the correct hardware address. 
>
>However, a kernel PANIC occurs any time an attempt is made to read or
>write to the hardware adaptor's addresses.

Your code samples below show that you're reading the adapter's physical
address, not a virtual one.   You need a virtual address for these accesses.


>The software environment is SCO 3.2v4.2 with development system.
>The hardware is clone Pentium.



Part of me wonders why you're developing on an OS that was obsolete 
almost seven years ago, but I won't dwell on that now, since the answer
is the same for current OpenServer, too.

>I have not been able to obtain access to a copy of SCO's device driver
>writers manual which is clearly what I need. Nevertheless, I have got
>this far with the following publications:

Fortunately, most of what you need is available on line.   The Hardware
Developer Kit (HDK) is available online at: 
        http://www.sco.com/developers/hdk/
While it's less than intuitive, goto:
        http://www.sco.com/support/docs/
and folow OpenUNIX 8 (the HDK doc set between OpenServer, UnixWare, 
and OpenUNIX is unified, but the OpenServer entry point on the web is 
"broken") and follow hardware and driver development.

>a). "Writing a UNIX Device Driver" , Janet I. Eagan & Thomas
>J.Teixeira published by Wiley, &
>
>b). "Writing UNIX Device Drivers", George Pajari, published by Addison
>Wesley.
>
>Both books have provided almost all that was needed up until now.

The FAQ for c.u.s.p. lists a few others, too.

>However, while Pajari's book deals specifically with SCO UNIX, he
>makes only passing reference to the fact that some adaptor cards might
>access dual port memory.

I recall that outtage.   I think I also recall a chapter or two that
was missing in my copy. ;-)

>The first mentioned book appears to explain how to do it, but the
>method does not seem to suit SCO UNIX.  

Correct.  This is one of the corners of device driver programming that's
different in all OSes.  (Well, except in UDI where udi_pio_map is exactly
the same in all OSes....)

>    int     symax_addr      =       SYMAX__0_SCMA;
>.
>struct mailbox *MB;     /* hardware data structure defined earlier */
>.
>.   
>MB = (struct mailbox * ) symax_addr;  /* Get the Hardware address */
>
>MB->nim_parameters = restart;         /* Reset the SyMax card */
>.
>.
>==============================================
>Clearly there is something important missing here.
>Any assistance would be greatly appreciated. 

You need to pass that physical address to sptalloc to get a mapped virtual
address.   So that is approximately like:

        MP=sptalloc(1, PG_P | PG_PCD, btoc(symax_addr), NOSLEEP);

You also probably need to tag this identifier as volatile to stop the
optimizer from getting clever on your hardware accesses.   AFAIR, that
version of the optimizer is too stupid to get too ambitious in this 
regard, but making accesses through MB volatile will save you grief.

RJL


If this page was useful to you, please click to help others find it:  

Your +1's can help friends, contacts, and others on the web find the best stuff when they search.

Comments?



Click here to add your comments



Don't miss responses! Subscribe to Comments by RSS or by Email

Click here to add your comments


If you want a picture to show with your comment, go get a Gravatar



ad

Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.

Publishing your articles here

Jump to Comments



Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.

Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.

We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.

g_face.jpg

This post tagged:

       - Kernel
       - Memory
       - Programming
       - SCO_OSR5




Unix/Linux Consultants

Skills Tests

Guest Post Here