Next Previous Contents

3. cbm4linux API

All communication between the user space applications and the kernel module is done with ioctl's. Since ioctl's are quite unportable and hardly provide any type-safety, there are a number of wrapper-functions along with a couple of convenience functions implemented in libcbm4linux.a. The Prototypes can be found in cbm4linux.h>.

3.1 Preprocessor macros

These defines are used by the cbm_iec_*() functions. You will definitely need this if you intend to implement your own custom transfer routines. See the d64copy source for more information.

3.2 Variables

const char cbm_dev[];

This is the name of the cbm4linux character device. Normally /dev/cbm. This file needs to be opened to access any cbm4linux functionality.

3.3 Functions

(All functions: f must be a valid file descriptor)

int cbm_listen(int f, __u_char dev, __u_char secadr);

Tell device dev to listen on secondary channel secadr. Return value 0 on success, < 0 means error.

int cbm_talk(int f, __u_char dev, __u_char secadr);

Tell device dev to talk on secondary channel secadr. Return value 0 on success, < 0 means error.

int cbm_open(int f, __u_char dev, __u_char secadr);

Prepare device dev for opening a file. This device listens for the file name after this call which is normally sent by a call to the write()-function followed by an unlisten() call. Return value 0 on success, < 0 means error.

int cbm_close(int f, __u_char dev, __u_char secadr);

Close file associated with secondard address secadr on device dev. Return value 0 on success, < 0 means error.

int cbm_unlisten(int f);

Send unlisten on bus. Return value 0 on success, < 0 means error.

int cbm_untalk(int f);

Send untalk on bus. Return value 0 on success, < 0 means error. descriptor.

int cbm_get_eoi(int f);

Get EOI flag after bus read, return velue is 0 with no EOI, otherwise 1. When EOI is set to 1, the active talker has nothing more to send.

int cbm_reset(int f);

Do a hardware reset on all connected devices. Control is returned after a 5 second delay.

__u_char cbm_pp_read(int f);

Read byte from XP1541/XP1571 bus. No hardshaking or such involved.

void cbm_pp_write(int f, __u_char c);

Write byte to XP1541/XP1571 bus. No hardshaking or such involved.

int cbm_iec_poll(int f);

Read status of all bus lines. Return value if a combination of IEC_ATN, IEC_CLOCK and IEC_DATA.

int cbm_iec_get(int f, int line);

Get (logical) status of line line.

void cbm_iec_set(int f, int line);

Activate line line (set to 0V).

void cbm_iec_release(int f, int line);

Release line line (set to 5V).

int cbm_iec_wait(int f, int line, int state);

Experimental.

int cbm_upload(int f, __u_char dev, int adr, __u_char *prog, int size);

Write prog into device dev's memory space via a series of M-W commands.

int cbm_device_status(int f, int drv, char *buf, int bufsize);

Read device status info buf, at most bufsize bytes are read. Returns atoi(buf).

int cbm_exec_command(int f, int drv, char *cmd, int len);

Execute command cmd. Returns number of bytes actually written.


Next Previous Contents