Next Previous Contents

3.3 Functions

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

Basic I/O

int cbm_driver_open(CBM_FILE *f, int port);

Opens the driver. port isn't used by now and should be 0. After successful completition, 0 is returned along with a valid CBM_FILE descriptor in f.

void cbm_driver_close(CBM_FILE f);

Closes the driver.

int cbm_raw_read(CBM_FILE f, void *buf, size_t size);

Retrive data after cbm_talk();. At most size bytes are read. Return value is the actual number of bytes read. < indicates an error.

int cbm_raw_write(CBM_FILE f, const void *buf, size_t size);

Send data after cbm_listen();. At most size bytes are written, Return value is the actual number of bytes written. < indicates an error.

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

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

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

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

int cbm_open(CBM_FILE 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(CBM_FILE f, __u_char dev, __u_char secadr);

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

int cbm_unlisten(CBM_FILE f);

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

int cbm_untalk(CBM_FILE f);

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

int cbm_get_eoi(CBM_FILE f);

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

int cbm_reset(CBM_FILE f);

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

Low-level port access

__u_char cbm_pp_read(CBM_FILE f);

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

void cbm_pp_write(CBM_FILE f, __u_char c);

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

int cbm_iec_poll(CBM_FILE f);

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

int cbm_iec_get(CBM_FILE f, int line);

Get (logical) status of line line.

void cbm_iec_set(CBM_FILE f, int line);

Activate line line (set to 0V).

void cbm_iec_release(CBM_FILE f, int line);

Release line line (set to 5V).

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

Experimental.

Helper functions

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

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

int cbm_device_status(CBM_FILE f, int drv, void *buf, int bufsize);

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

int cbm_exec_command(CBM_FILE f, int drv, void *cmd, int len);

Execute command cmd. Returns number of bytes actually written.

int cbm_identify(CBM_FILE f, int drv, enum cbm_device_type_e *t, const char **type_str);

Tries to identify the device drv. The hardware type is returned in t, type_str contains a descriptive string which also includes the drives' operating system. Both t and type_str may be NULL in case the caller is not interrested in any of both values.

The return value is 0 if the device responded to the "M-R" command, even if it could not be identified, < 0 indicates error.

libd64copy TODO

Not documented yet. See libd64copy and d64copy source.

Types and prototypes are defined in d64copy.h.

libcbmcopy TODO

Not documented yet. See libcbmcopy and cbmcopy source.

Types and prototypes are defined in cbmcopy.h.


Next Previous Contents