/* Copyright (C) Magna Carta Software, Inc. 1990-1991. All Rights Reserved Routines to support the Star Gate ACL series of multiport boards. ACL00.C -- This file contains the lowest level routines. They implement an API to call the ACL Family Control Program. */ #define CCT_DEVELOPMENT #include #include #if defined(__TURBOC__) #include #elif (defined(MSC) || defined(__WATCOMC__)) #include #endif /* ACL_CMD -- Send a command to the ACL and return the Global Status Word Parameters: ACL_GCB *acl -- ptr. to the Global Control Block structure; cmd -- command to send to the board. Return Value: the value of the Global Status Word; */ short acl_cmd(ACL *acl, WORD cmd) { * ((WORD *) acl->base_addr) = cmd; while (*acl->base_addr != 0); return (acl_gsw(acl)); } /* ACL_INIT -- Initialize CCT for the Star Gate ACL board and initialize the ACL board. */ short acl_init(ACL *acl, WORD port_addr, void FAR_ *base_addr) { short ret; /* outp(port_addr + 4, 0); */ /* initialize megabyte map register */ acl->port_addr = port_addr; ret = acl_ram_enable(acl, base_addr); return (ret); } /* ACL_RAM_DISABLE -- Disable the dual port RAM on the specified ACL board. */ void acl_ram_disable(ACL *acl) { outp(acl->port_addr, (WORD) ((long) acl->base_addr >> 24)); } /* ACL_RAM_ENABLE -- Enable the dual port RAM on the specified ACL board to use the specified address. */ short acl_ram_enable(ACL *acl, void FAR_ *base_addr) { short ret, ver; outp(acl->port_addr, (WORD) ((long) base_addr >> 24) | 1); acl->base_addr = base_addr; ret = acl_cmd(acl, 0); if (!ret) { acl->cba = (BYTE FAR_ *) acl->base_addr + acl_ccb_offset(acl); /* CHECK ACL CP IS LOADED BY GETTING CP VERSION */ ver = acl_cp_ver(acl); if (!ver) ret = EOF; } return (ret); } /* ========= CHANNEL COMMANDS ========= */ /* ACL_CH_GET -- Read ACL channel configuration parameter. Parameters: char *cba -- Channel Control Block address; WORD parm -- desired parameter; Return Value: the value of the desired parameter; */ short acl_ch_get(char *cba, WORD parm) { return (*((WORD FAR_ *) (cba + parm))); } /* ACL_CC -- ACL channel command. Send command, wait for Channel Command Word to return to zero, return value of Channel Status Word. Parameters: ACL_GCB *acl -- ptr. to the Global Control Block structure; WORD cmd -- command to send to ACL; Return Value: the value of the Channel Status Word; */ short acl_cc(char *cba, WORD cmd) { *((WORD FAR_ *)(cba + ACL_CHANNEL_COMMAND)) = cmd; while (acl_ch_get(cba, ACL_CHANNEL_COMMAND)); return (acl_ch_get(cba, ACL_CHANNEL_STATUS)); } /* ACL_CH_CMD -- Send a channel command to the ACL channel. Parameters: char *cba -- ptr. to the Channel Control Block structure; WORD cmd -- desired command; WORD parm -- parameter to command; Return Value: the value of the Channel Status Word; */ short acl_ch_cmd(char *cba, WORD cmd, WORD parm) { * ((WORD FAR_ *)(cba + cmd)) = parm; return (acl_cc(cba, CCAU)); } /* ACL_CH_SET-- Assign a value to an ACL channel control block. Do NOT send a command to the ACL. Parameters: char *cba -- ptr. to the Channel Control Block structure; WORD cmd -- desired command; WORD parm -- parameter to command; Return Value: the value of the Channel Status Word; */ short acl_ch_set(char *cba, WORD cmd, WORD parm) { * ((WORD FAR_ *)(cba + cmd)) = parm; return (parm); } /* ACL_CH_SET_DATA_FORMAT -- Set a data format parameter in the ACL channel. Parameters: ACL *acl -- ptr. to the Global Control Block structure; WORD cmd -- desired command; WORD parm -- parameter to command; Return Value: the value of the Channel Status Word; */ short acl_ch_set_data_format(char *cba, WORD parm) { return (acl_ch_cmd(cba, ACL_DATA_FORMAT, parm)); } /* ACL_CH_SET_LINE_PROTOCOL -- Set the line format in the ACL channel. Parameters: ACL *acl -- ptr. to the Global Control Block structure; WORD cmd -- desired command; WORD parm -- parameter to command; Return Value: the value of the Channel Status Word; */ short acl_ch_set_line_protocol(char *cba, WORD parm) { return (acl_ch_cmd(cba, ACL_LINE_PROTOCOL, parm)); } /* ACL_CH_SET_DATABITS -- Set the number of data bits for an ACL channel. Parameters: ACL *acl -- ptr. to the ACL structure; WORD databits -- desired number of data bits; Return Value: the value of the Channel Status Word; */ short acl_ch_set_databits(char *cba, WORD databits) { WORD format = (acl_ch_get(cba, ACL_DATA_FORMAT) & 0XFC) | databits - 5; return (acl_ch_set_data_format(cba, format)); } /* ACL_CH_SET_PARITY -- Set the parity for an ACL channel. Parameters: ACL *acl -- ptr. to the ACL structure; WORD parity -- desired parity; Return Value: the value of the Channel Status Word; */ short acl_ch_set_parity(char *cba, WORD parity) { WORD format = (acl_ch_get(cba, ACL_DATA_FORMAT) & 0XC7) | parity; return (acl_ch_set_data_format(cba, format)); } /* ACL_CH_SET_STOPBITS -- Set the number of stop bits for an ACL channel. Parameters: ACL *acl -- ptr. to the ACL structure; WORD stopbits -- desired number of stop bits; Return Value: the value of the Channel Status Word; */ short acl_ch_set_stopbits(char *cba, WORD stopbits) { WORD format = (acl_ch_get(cba, ACL_DATA_FORMAT) & 0XFB) | stopbits; return (acl_ch_set_data_format(cba, format)); }