[comp.sys.amiga.tech] CIA Resource Allocation

mcmahan@netcom.UUCP (Dave Mc Mahan) (04/08/90)

I have been experimenting with using the OpenResource() call to obtain use
of the CIA-B resource.  It appears that there is no CloseResource() call.
This function call is referenced in my RKM 1.1 manuals in the OpenResource()
description, but my linker can't find it, and it doesn't have an entry in
my RKM manual.  Is there such a thing?  

While we are on the topic, what does OpenResource() do?  I thought it would
give me exclusive access to the CIA-B resource.  Upon multiple runnings of
my program, I find that I can always succesfully allocate the resource.  There
appears to be no exclusivity involved.  Is this correct?  Once I do the
OpenResource() call, do I just go ahead and start programming the chip
registers directly, or should I go through some system calls?  I get a pointer
back from OpenResource(), what do I do with it, besides use it to make the
AbleICR(), AddICRVector(), RemICRVector(), and SetICR() function calls?  Is
there ever a time when OpenResource() will return saying I can't access the
resource?

Lastly, OpenResource() returns a pointer of a structure of type Library.
I can't seem to find a declaration for the Library structure in any of my
include files, but the program still compiles.  Upon further testing, the
Library structure appears to have no length. (I found this out by trying
to increment the pointer returned.  It comes back with the same value)
Where is the Library structure declared?

   -dave

riley@batcomputer.tn.cornell.edu (Daniel S. Riley) (04/08/90)

In article <10670@netcom.UUCP> mcmahan@netcom.UUCP (Dave Mc Mahan) writes:
>I have been experimenting with using the OpenResource() call to obtain use
>of the CIA-B resource.  It appears that there is no CloseResource() call.
>This function call is referenced in my RKM 1.1 manuals in the OpenResource()
>description, but my linker can't find it, and it doesn't have an entry in
>my RKM manual.  Is there such a thing?  

Nope.  OpenResource() just returns a pointer to the resource, it does not
give you exclusive access.  There's a GetMiscResource() that does allocate,
but the only miscellaneous resources are the serial and parallel bits and
port (4 misc resources total).  For the CIA's, you get exclusive access
by using AddICRVector(), which fails if the interrupt bit you try to
allocate is already in use.

Recommended reading includes the AmigaMail article by Adam Levin and
Paul Higginbottom on a timer program using the CIA resource.  Slightly
modified versions of this code by Karl Lehenbauer and Pete Yadlowsky
have been posted to Usenet in the last year or so.

>Lastly, OpenResource() returns a pointer of a structure of type Library.
[...]
>Where is the Library structure declared?

Try exec/libraries.h.

-Dan Riley (riley@tcgould.tn.cornell.edu, cornell!batcomputer!riley)
-Wilson Lab, Cornell University

valentin@cbmvax.commodore.com (Valentin Pepelea) (04/09/90)

In article <10670@netcom.UUCP> mcmahan@netcom.UUCP (Dave Mc Mahan) writes:
>
> It appears that there is no CloseResource() call.

There's no point having one, since the resource will not ever be expunged.

>This function call is referenced in my RKM 1.1 manuals in the OpenResource()
>description, but my linker can't find it,

It should be in the Exec library.

>While we are on the topic, what does OpenResource() do?  I thought it would
>give me exclusive access to the CIA-B resource.

It merely returns a pointer to the CIA resource base, just like OpenLibrary()
returns a pointer to a library base. It does not give you exclusive access to
anythin. For exclusive access to the parallel or serial devices, you must grab
the corresponding resource bits. An example can be found in AmigaMail, the
newsletter published by CATS.

>Lastly, OpenResource() returns a pointer of a structure of type Library.
>I can't seem to find a declaration for the Library structure in any of my
>include files, but the program still compiles.  Upon further testing, the
>Library structure appears to have no length.

The include:hardware/cia.h file is all you need. The cia resource base
structure is not published because you do not need to use anything inside it;
all the entries in there are for the related functions' private use.

Valentin
-- 
The Goddess of democracy? "The tyrants     Name:    Valentin Pepelea
may distroy a statue,  but they cannot     Phone:   (215) 431-9327
kill a god."                               UseNet:  cbmvax!valentin@uunet.uu.net
             - Ancient Chinese Proverb     Claimer: I not Commodore spokesman be

mk59200@korppi.tut.fi (Kolkka Markku Olavi) (04/10/90)

While we are discussing resources, here are a couple of problems
I found in the Includes & Autodocs manual:

- On page A-34 and in the examples of section C, OpenResource() is
  defined as OpenResource(resname), on page H-2 and in the 1.3.2
  .fd files give it as OpenResource(resname, version).

- RemICRVector() is defined with two parameters on page C-3,
  but with only one parameter on page H-1.

Which are the correct definitions?

--
	Markku Kolkka
	mk59200@tut.fi