Table of Contents

There are 4 classes of device drivers that Portfolio OS supports:

I'll describe each class below.

Common for most drivers is the device creation process. Please read Items, tag_args, signals and i/o architecture basics before proceeding.

Creating of the named device steps :

  1. You are in privileged main, but not in SVC mode. You can use SWI here, but do not access HW!!!
  2. Create KERNELNODE+DRIVERNODE Item with a minimum of following tags - that will be your actual driver work:
    1. TAG_ITEM_PRI (should be less than real time - pri>=1)
    2. TAG_ITEM_NAME - the name of your driver. Not the name of your named device!!
    3. CREATEDRIVER_TAG_MAXCMDS, minimum 3 driver commands : driver_write, driver_read, driver_status
    4. CREATEDRIVER_TAG_CMDTABLE , driver_cmdtable array of function pointers for the driver commands.
    5. CREATEDRIVER_TAG_INIT - driver_init function – do all the HW init stuff here.
    6. CREATEDRIVER_TAG_ABORTIO - driver_abortio function
  3. Create KERNELNODE+DEVICENOTE Item with a minimum of following tags - that will be your named device interface:
    1. TAG_ITEM_PRI (should be much less than real time, pri >=128)
    2. TAG_ITEM_NAME - the name of your named device. Used in “OpenNamedDevice()” call.
    3. CREATEDEVICE_TAG_DRVR - the item of your device driver – result of the previous step
    4. CREATEDEVICE_TAG_INIT - dev_init function of your named device – clear your reference counters, no HW work here
    5. CREATEDEVICE_TAG_OPEN - dev_open function of your named device – increment usage counter, and tell HW that it is open if counter was 0
    6. CREATEDEVICE_TAG_CLOSE - dev_close function of your named device – decrement usage counter, and tell HW that it is closed if counter reached 0
  4. Optionally obtain parent's id for the signal loop
  5. AllocSignal with mask 0 or what ever parent may send us
  6. enter the loop, with WaitSignal, and exit the loop if “SIGF_ABORT” was received
  7. clean after yourself.

Function overview :

All functions in SVC content must use non-swi style of Folio syscalls.. You cannot use SWI !!!!. See sample project's kernel_calls.s as example of how to access kernel syscalls.

Device classes:

CPort driver header :

typedef struct{

uint32 headerchecksum;

uint32 filesize;

uint32 familycode;

uint32 familyversion;

uint32 imagechecksum;

uint32 pad[3];

} cport_hdr_t;

NOTE : All privileged aifs must be signed by appropriate key (depending on flag 4).