30.12.2013 Views

T-Kernel Specification (1.B0.02)

T-Kernel Specification (1.B0.02)

T-Kernel Specification (1.B0.02)

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

4.10. SUBSYSTEM MANAGEMENT FUNCTIONS 209<br />

void cleanupfn( ID resid, INT info )<br />

{<br />

/*<br />

Resource release processing<br />

*/<br />

}<br />

resid is the ID of the resource group subject to resource release, while info is a parameter that<br />

can be used freely. Both are parameters passed to tk cln ssy.<br />

Even if resource release fails for some reason, the cleanup function must be terminated normally.<br />

The error handling, such as logging of errors, can be decided for each subsystem.<br />

After the cleanup function completes its processing, the resource control block is automatically<br />

cleared to 0. If no cleanup function was defined (cleanupfn = NULL), the tk cln ssy system call<br />

clears the resource control block to 0.<br />

A cleanup function runs as a quasi-task portion in the context of the task that called tk cln ssy.<br />

• Event handling function<br />

An event handling function is called by issuing the tk evt ssy system call. It processes various<br />

requests made to a subsystem. Note that it does not carry the obligation to process all requests<br />

for all subsystems. If processing is not required, it can simply return E OK without performing any<br />

operation.<br />

The format of an event handling function is as follows.<br />

ER eventfn( INT evttyp, ID resid, INT info )<br />

{<br />

/*<br />

Event processing<br />

*/<br />

return ercd;<br />

}<br />

evttyp indicates the request type, resid gives the ID of the resource group, and info is a parameter<br />

that can be used freely. All these parameters are passed to tk evt ssy. If the system call is not<br />

invoked for any particular resource group, resid can be set to 0.<br />

If processing completes normally, E OK is passed in the return code; otherwise an error code<br />

(negative value) is returned.<br />

The following event types evttyp are defined. See 5.3 for details.<br />

#define TSEVT_SUSPEND_BEGIN 1 /* before suspending device */<br />

#define TSEVT_SUSPEND_DONE 2 /* after suspending device */<br />

#define TSEVT_RESUME_BEGIN 3 /* before resuming device */<br />

#define TSEVT_RESUME_DONE 4 /* after resuming device */<br />

#define TSEVT_DEVICE_REGIST 5 /* device registration notice */<br />

#define TSEVT_DEVICE_DELETE 6 /* device deletion notice */<br />

An event handling function runs as a quasi-task portion in the context of the task that called<br />

tk evt ssy.<br />

Copyright c○ 2002, 2003 by T-Engine Forum<br />

T-<strong>Kernel</strong> <strong>1.B0.02</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!