One of the design goals for the Amiga OS was to make the system dynamic enough so that the OS could be extended and updated without effecting existing applications. Another design goal was to make it easy for different applications to be able to share common pieces of code. The Amiga accomplished these goals through a system of libraries. An Amiga library consists of a collection of related functions which can be anywhere in system memory (RAM or ROM). Devices are very similar to libraries, except they usually control some sort of I/O device and contain some extra standard functions. Although this section does not really discuss devices directly, the material here applies to them. For more information on devices, see the "exec device i/o" section of this manual or the Amiga ROM Kernel Reference Manual: devices. An application accesses a library's functions through the library's jump, or vector, table. Before a task can use the functions of a particular library, it must first acquire the library's base pointer by calling the Exec openlibrary() function: struct Library *OpenLibrary( UBYTE *libName, unsigned long mylibversion ); where libName is a string naming the library and mylibversion is a version number for the library. The version number reflects a revision of the system software. The chart below lists the specific Amiga OS release versions that system libraries versions correspond to: 30 Kickstart 1.0 - This revision is obsolete. 31 Kickstart 1.1 - This was an NTSC only release and is obsolete. 32 Kickstart 1.1 - This was a PAL only release and is obsolete. 33 Kickstart 1.2 - This is the oldest revision of the OS still in use. 34 Kickstart 1.3 - This is almost the same as release 1.2 except it has an Autobooting expansion.library 35 This is a special RAM-loaded version of the 1.3 revision, except that it knows about the A2024 display modes. No application should need this library unless they need to open an A2024 display mode under 1.3. 36 Kickstart 2.0 - This is the original Release 2 revision that was initially shipped on early Amiga 3000 models. 37 Kickstart 2.04 - This is the general Release 2 revision for all Amiga models. The openlibrary() function looks for a library with a name that matches libName and also with a version at least as high as mylibversion. For example, to open version 33 or greater of the Intuition library: IntuitionBase = OpenLibrary("intuition.library", 33L); In this example, if version 33 or greater of the Intuition library is not available, openlibrary() returns null. a version of zero in openlibrary() tells the OS to open any version of the library. Unless your code requires Release 2 features, it should specify a version number of 33 to remain backwards compatible with Kickstart 1.2. When openlibrary() looks for a library, it first looks in memory. if the library is not in memory, OpenLibrary() will look for the library on disk. If libName is a library name with an absolute path (for example, "myapp:mylibs/mylib.library"), OpenLibrary() will follow that absolute path looking for the library. If libName is only a library name ("diskfont.library"), openlibrary() will look for the library in the directory that the LIBS: logical assign currently references. If openlibrary() finds the library on disk, it takes care of loading it and initializing it. As part of the initialization process, OpenLibrary() dynamically creates a jump, or vector, table. There is a vector for each function in the library. Each entry in the table consists of a 680x0 jump instruction (JMP) to one of the library functions. The OS needs to create the vector table dynamically because the library functions can be anywhere in memory. After the library is loaded into memory and initialized, openlibrary() can actually "open" the library. It does this by calling the library's open function vector. Every library has a standard vector set aside for an OPEN function so the library can set up any data or processes that it needs. Normally, a library's OPEN function increments its open count to keep track of how many tasks currently have the library opened. If any step of openlibrary() fails, it returns a null value. if OpenLibrary() is successful, it returns the address of the library base. The library base is the address of this library's library structure (defined in <exec/libraries.h>). the library structure immediately follows the vector table in memory. After an application is finished with a library, it must close it by calling closelibrary(): void CloseLibrary(struct Library *libPtr); where libPtr is a pointer to the library base returned when the library was opened with openlibrary(). library vector offsets (lvos) calling a library function