Chapter 3. Library SWI Calls
Prev | RISC OS USB SWI API | Next

## Chapter 3. Library SWI Calls

## 3.1. Introduction

This Module provides support calls for the USB system. Every call here can be implemented using discrete calls from the "core" module and structure manipulation.

The SWIs here adhere to the standard RISC OS error reporting mechanism. A Call returning with the V flag set indicates that the data pointed to by R0 on exit is an error block and the call has failed

The SWIs provided here break down into three general categories

Interfacing to functionality similar to the C API
Creation of standard structures E.G. waiting structures
Manipulation of standard structures

Where appropriate links will be provided to their equivalents in the RISC OS USB C API.

## 3.2. Notes on reference counts

All HostController, Endpoint and Device references have an associated reference count. This count is incremented by the associated find calls for them, and needs to be decremented when they are no-longer of use to the driver. A reference can be de-registered by USBLib_ReferenceDeregister (SWI &56340) which will take one off the reference count. When the reference count reaches zero, the reference will finally be deleted from the system, freeing up any associated resources.

If the reference counts are not suitably de-registered, then you will leave references and their resources in the system, and will therefore leave less room for new resources.

The reference count of of endpoints created when the device is first obtained by the driver may well not be zero, drivers should not assume this behaviour and should balance claims and releases accordingly.

## 3.3. Reference management SWIs

## 3.4. Waiting Support SWIs

## 3.5. Transaction SWIs

## 3.6. Device management SWIs

## 3.7. Library SWIs

## 3.8. URB SWIs

Prev | Up | Next
USB_Version (SWI&5539C) | Home | USBLib_FindDeviceRef (SWI &56340)