Copyright (c) Hyperion Entertainment and contributors.

Difference between revisions of "Exec Resources"

From AmigaOS Documentation Wiki
Jump to navigation Jump to search
 
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{WIP}}
 
 
== Introduction ==
 
== Introduction ==
   
Line 6: Line 5:
 
== The Amiga Resources ==
 
== The Amiga Resources ==
   
There are currently seven standard resources in the Amiga system. The following lists the name of each resource and its function.
+
There are many standard resources in the Amiga system. Each system may have different resources available depending on the hardware platform. The following lists some resources including the name of the resource and its function.
   
 
{| class="wikitable"
 
{| class="wikitable"
| battclock.resource || grants access to the battery-backed clock chip.
+
| [[battclock.resource]] || grants access to the battery-backed clock chip.
 
|-
 
|-
| battmem.resource || grants access to non-volatile RAM.
+
| [[battmem.resource]] || grants access to non-volatile RAM.
 
|-
 
|-
| cia.resource || grants access to the interrupts and timer bits of the 8520 CIA (Complex Interface Adapter) chips.
+
| [[cia.resource]] || grants access to the interrupts and timer bits of the 8520 CIA (Complex Interface Adapter) chips.
 
|-
 
|-
| disk.resource || grants temporary exclusive access to the disk hardware.
+
| [[disk.resource]] || grants temporary exclusive access to the disk hardware.
 
|-
 
|-
| FileSystem.resource || grants access to the file system.
+
| [[FileSystem.resource]] || grants access to the file system.
 
|-
 
|-
| misc.resource || grants exclusive access to functional blocks of chip registers. At present, definitions have been made for the serial and parallel hardware only.
+
| [[misc.resource]] || grants exclusive access to functional blocks of chip registers. At present, definitions have been made for the serial and parallel hardware only.
 
|-
 
|-
| potgo.resource || manages the bits of the proportional I/O pins on the game controller ports.
+
| [[potgo.resource]] || manages the bits of the proportional I/O pins on the game controller ports.
 
|-
 
|-
| xena.resource || grants access to the Xena chip.
+
| [[Xena_Resource|xena.resource]] || grants access to the Xena chip.
 
|}
 
|}
   
Line 30: Line 29:
 
See the ''Amiga Hardware Reference Manual'' for detailed information on the actual hardware involved.
 
See the ''Amiga Hardware Reference Manual'' for detailed information on the actual hardware involved.
   
  +
{{Note|title=Look Before You Leap|text=Resources are just one step above direct hardware manipulation. You are advised to try the higher level device and library approach before resorting to the hardware.}}
{| class="wikitable"
 
| ''Look Before You Leap''. Resources are just one step above direct hardware manipulation. You are advised to try the higher level device and library approach before resorting to the hardware.
 
|}
 
   
 
== Resource Interface ==
 
== Resource Interface ==
Line 49: Line 46:
 
</syntaxhighlight>
 
</syntaxhighlight>
   
There is no CloseResource() function. When you are done with a resource, you are done with it. However, as you will see later in this chapter, some resources provide functions to allocate parts of the hardware they access. In those cases, you will have to free those parts for anyone else to use them.
+
There is no CloseResource() function. When you are done with a resource, you are done with it. However, as you will see below, some resources provide functions to allocate parts of the hardware they access. In those cases, you will have to free those parts for anyone else to use them.
   
Each resource has at least one include file in the resources subdirectory of the include directory. Some of the include files contain only the name of the resource; others list structures and bit definitions used by the resource. The include files will be listed at the end of this chapter.
+
Each resource has at least one include file in the resources subdirectory of the include directory. Some of the include files contain only the name of the resource; others list structures and bit definitions used by the resource. The include files will be listed at the end of this article.
   
 
Calling a resource function is the same as calling any other function on the Amiga. You have to know what parameters it accepts and the return value, if any. The Autodocs for each resource lists the functions and their requirements.
 
Calling a resource function is the same as calling any other function on the Amiga. You have to know what parameters it accepts and the return value, if any. The Autodocs for each resource lists the functions and their requirements.
Line 58: Line 55:
 
#include <hardware/cia.h>
 
#include <hardware/cia.h>
 
#include <resources/cia.h>
 
#include <resources/cia.h>
  +
  +
#include <proto/exec.h>
  +
#include <proto/dos.h>
   
 
struct Library *CIAResource = NULL;
 
struct Library *CIAResource = NULL;
   
void main()
+
ing main()
 
{
 
{
  +
int16 mask = 0;
 
WORD mask = 0;
 
   
 
if (!(CIAResource = IExec->OpenResource(CIABNAME)))
 
if (!(CIAResource = IExec->OpenResource(CIABNAME)))
printf(&quot;Cannot open %s\n", CIABNAME);
+
IDOS->Printf("Cannot open %s\n", CIABNAME);
 
else
 
else
 
{
 
{
Line 73: Line 72:
 
mask = AbleICR(CIAResource, 0);
 
mask = AbleICR(CIAResource, 0);
   
IDOS->Printf("\nThe CIA interrupt enable mask: %x \n", mask);
+
IDOS->Printf("\nThe CIA interrupt enable mask: 0x%x \n", mask);
 
}
 
}
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>
   
  +
{{Note|title=Looks Can Be Deceiving|text=Some resources may look like libraries and act like libraries, but be assured they are not libraries.}}
{| class="wikitable"
 
| ''Looks Can Be Deceiving''. Some resources may look like libraries and act like libraries, but be assured they are not libraries.
 
|}
 

Latest revision as of 18:45, 4 November 2015

Introduction

The Amiga’s low-level hardware control functions are collectively referred to as “Resources”. Most applications will never need to use the hardware at the resource level—the Amiga’s device interface is much more convenient and provides for multitasking. However, some high performance applications, such as MIDI time stamping, may require direct access to the Amiga hardware registers.

The Amiga Resources

There are many standard resources in the Amiga system. Each system may have different resources available depending on the hardware platform. The following lists some resources including the name of the resource and its function.

battclock.resource grants access to the battery-backed clock chip.
battmem.resource grants access to non-volatile RAM.
cia.resource grants access to the interrupts and timer bits of the 8520 CIA (Complex Interface Adapter) chips.
disk.resource grants temporary exclusive access to the disk hardware.
FileSystem.resource grants access to the file system.
misc.resource grants exclusive access to functional blocks of chip registers. At present, definitions have been made for the serial and parallel hardware only.
potgo.resource manages the bits of the proportional I/O pins on the game controller ports.
xena.resource grants access to the Xena chip.

The resources allow you direct access to the hardware in a way that is compatible with multitasking. They also allow you to temporarily bar other tasks from using the resource. You may then use the associated hardware directly for your special purposes. If applicable, you must return the resource back to the system for other tasks to use when you are finished with it.

See the Amiga Hardware Reference Manual for detailed information on the actual hardware involved.

Look Before You Leap
Resources are just one step above direct hardware manipulation. You are advised to try the higher level device and library approach before resorting to the hardware.

Resource Interface

Resources provide functions that you call to do low-level operations with the hardware they access. In order to use the functions of a resource, you must obtain a pointer to the resource. This is done by calling the OpenResource() function with the resource name as its argument.

OpenResource() returns a pointer to the resource you request or NULL if it does not exist.

#include <resources/filesysres.h>
 
struct FileSysResource *FileSysResBase = NULL;
 
if (!(FileSysResBase = IExec->OpenResource(FSRNAME)))
    IDOS->Printf("Cannot open %s\n", FSRNAME);

There is no CloseResource() function. When you are done with a resource, you are done with it. However, as you will see below, some resources provide functions to allocate parts of the hardware they access. In those cases, you will have to free those parts for anyone else to use them.

Each resource has at least one include file in the resources subdirectory of the include directory. Some of the include files contain only the name of the resource; others list structures and bit definitions used by the resource. The include files will be listed at the end of this article.

Calling a resource function is the same as calling any other function on the Amiga. You have to know what parameters it accepts and the return value, if any. The Autodocs for each resource lists the functions and their requirements.

#include <hardware/cia.h>
#include <resources/cia.h>
 
#include <proto/exec.h>
#include <proto/dos.h>
 
struct Library *CIAResource = NULL;
 
ing main()
{
int16 mask = 0;
 
if (!(CIAResource = IExec->OpenResource(CIABNAME)))
    IDOS->Printf("Cannot open %s\n", CIABNAME);
else
   {
    /* What is the interrupt enable mask? */
     mask = AbleICR(CIAResource, 0);
 
    IDOS->Printf("\nThe CIA interrupt enable mask: 0x%x \n", mask);
   }
}
Looks Can Be Deceiving
Some resources may look like libraries and act like libraries, but be assured they are not libraries.