tk_opn_dev

Open Device

[C Language Interface]




ID devid = tk_opn_dev ( UB *devnm, UINT omode ) ;

[Parameters]

UB*	devnm	Device name


UINT	omode	Open mode

[Return Parameters]

ID	devid	Device descriptor


	or	Error code

[Error Codes]

E_BUSY		Device busy (exclusive open)


E_NOEXS		Device does not exist


E_LIMIT		Open count exceeds the limit


Other		Errors returned by device driver

[Description]

Opens the device specified in devnm in the mode specified in omode, and prepares for device access. The device descriptor is passed in the return code.

omode := (TD_READ || TD_WRITE || TD_UPDATE) | TD_EXCL@ || @TD_WEXCL


#define	TD_READ	0x0001	/* read only	*/
#define	TD_WRITE	0x0002	/* write only	*/
#define	TD_UPDATE	0x0003	/* read/write	*/
#define	TD_EXCL	0x0100	/* exclusive	*/
#define	TD_WEXCL	0x0200	/* exclusive write	*/
#define	TD_REXCL	0x0400	/* exclusive read	*/

TD_READ Read only

TD_WRITE Write only

TD_UPDATE Sets read and write access mode.

When TD_READ is set, tk_wri_dev cannot be used.

When TD_WRITE is set, tk_rea_dev cannot be used.

TD_EXCL Exclusive

TD_WEXCL Exclusive write

TD_REXCL Exclusive read

Sets the exclusive mode.

When TD_EXCL is set, all concurrent opening is prohibited.

When TD_WEXCL is set, concurrent opening in write mode (TD_WRITE or TD_UPDATE) is prohibited.

When TD_REXCL is set, concurrent opening in read mode (TD_READ or TD_UPDATE) is prohibited.

| Concurrent Open Mode |

Present Open Mode | No exclusive mode | TD_WEXCL

TD_REXCL

TD_EXCL

|

R | W | R | W | R | W | R | W |
No exclusive mode | R | Yes | Yes | Yes | Yes | No | No | No | No |
| W | Yes | Yes | No | No | Yes | Yes | No | No |
TD_WEXCL

R | Yes | No | Yes | No | No | No | No | No |
| W | Yes | No | No | No | Yes | No | No | No |
TD_REXCL

R | No | Yes | No | Yes | No | Yes | No | No |
| W | No | Yes | No | No | No | No | No | No |
TD_EXCL

R | No | No | No | No | No | Yes | No | No |
| W | No | No | No | No | No | No | No | No |
R= TD_READ W= TD_WRITE or TD_UPDATE

Yes = Can be opened No = Cannot be opened (E_BUSY)

When a physical device is opened, the logical devices belonging to it are all treated as having been opened in the same mode, and are processed as exclusive open.

[Difference with T-Kernel]

Unnecessary lock (TD_NOLOCK) does not exist in the attribute for ‘omode’. This is because there is no virtual memory and no concept of resident memory in µT-Kernel.

Comments

Click here to Post a Comment