ARPDAS_QNX6 1.0
|
#include <sys/neutrino.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <stdarg.h>
#include "subbus.h"
#include "nortlib.h"
#include "nl_assert.h"
#include "subbusd.h"
Go to the source code of this file.
Defines | |
#define | SUBBUS_VERSION 0x501 |
Functions | |
static int | send_to_subbusd (unsigned short command, void *data, int data_size, unsigned short exp_type) |
int | load_subbus (void) |
char * | get_subbus_name (void) |
int | read_ack (unsigned short addr, unsigned short *data) |
unsigned short | cache_read (unsigned short addr) |
unsigned short | read_subbus (unsigned short addr) |
unsigned short | sbrb (unsigned short addr) |
unsigned short | sbrba (unsigned short addr) |
unsigned int | sbrwa (unsigned short addr) |
int | write_ack (unsigned short addr, unsigned short data) |
int | cache_write (unsigned short addr, unsigned short data) |
static int | send_CSF (unsigned short command, unsigned short val) |
int | set_cmdenbl (int val) |
int | set_cmdstrobe (int val) |
int | set_failure (unsigned short value) |
static unsigned short | read_special (unsigned short command) |
unsigned short | read_switches (void) |
unsigned short | read_failure (void) |
int | tick_sic (void) |
int | disarm_sic (void) |
int | subbus_int_attach (char *cardID, unsigned short address, unsigned short region, struct sigevent *event) |
int | subbus_int_detach (char *cardID) |
int | subbus_quit (void) |
int | mread_subbus (subbus_mread_req *req, unsigned short *data) |
static subbus_mread_req * | pack_mread (int req_len, int n_reads, const char *req_str) |
subbus_mread_req * | pack_mread_requests (unsigned int addr,...) |
subbus_mread_req * | pack_mread_request (int n_reads, const char *req) |
Variables | |
static int | sb_fd = -1 |
static iov_t | sb_iov [3] |
static subbusd_req_hdr_t | sb_req_hdr |
static subbusd_rep_t | sb_reply |
static char | local_subbus_name [SUBBUS_NAME_MAX] |
unsigned short | subbus_version = SUBBUS_VERSION |
unsigned short | subbus_subfunction |
unsigned short | subbus_features |
unsigned short cache_read | ( | unsigned short | addr | ) |
Definition at line 137 of file subbus.c.
References subbusd_rep_t::data, subbusd_req_data1::data, nl_error, SBC_READCACHE, SBRT_US, SBS_ACK, SBS_NOACK, send_to_subbusd(), and subbusd_rep_t::value.
int cache_write | ( | unsigned short | addr, |
unsigned short | data | ||
) |
Definition at line 219 of file subbus.c.
References subbusd_req_data0::address, subbusd_req_data0::data, nl_error, SBC_WRITECACHE, SBRT_NONE, SBS_ACK, SBS_NOACK, and send_to_subbusd().
int disarm_sic | ( | void | ) |
If system controller is associated with a watchdog timer that can reboot the system, this command disables that timer.
Definition at line 350 of file subbus.c.
Referenced by incoming_sbreq().
char* get_subbus_name | ( | void | ) |
Returns the hardware name string as originally retrieved from subbusd during load_subbus().
Definition at line 107 of file subbus.c.
References local_subbus_name, nl_error, and sb_fd.
int load_subbus | ( | void | ) |
Initializes communications with subbusd driver. Returns library subfunction on success, zero on failure.
Definition at line 75 of file subbus.c.
References subbusd_rep_t::capabilities, subbusd_rep_t::data, subbusd_cap_t::features, subbusd_req_hdr_t::iohdr, local_subbus_name, subbusd_cap_t::name, nl_error, sb_fd, sb_iov, SB_KW, subbusd_req_hdr_t::sb_kw, SBC_GETCAPS, SBRT_CAP, SBS_OK, send_to_subbusd(), subbus_features, SUBBUS_NAME_MAX, subbus_subfunction, SUBBUSD_MGRID, and subbusd_cap_t::subfunc.
int mread_subbus | ( | subbus_mread_req * | req, |
unsigned short * | data | ||
) |
Passes the raw command directly to the subbus driver and parses the return string for a multi-read. Up to n_read values will be written into the array pointed to by the data argument.
Definition at line 392 of file subbus.c.
References subbusd_rep_t::data, subbusd_rep_t::mread, subbusd_mread_t::n_reads, subbus_mread_req::n_reads, nl_assert, subbus_mread_req::req_len, subbusd_mread_t::rvals, SBC_MREAD, SBRT_MREAD, and send_to_subbusd().
static subbus_mread_req* pack_mread | ( | int | req_len, |
int | n_reads, | ||
const char * | req_str | ||
) | [static] |
Packages a request string into a newly allocated structure that can be passed to mread_subbus(). Called by pack_mread_request() and pack_mread_requests(). The req_str syntax is:
<req> : M <count> '#' <addr_list> '
' <addr_list> : <addr_list_elt> : <addr_list> ',' <addr_list_elt> <addr_list_elt> : <addr> : <addr> ':' <incr> ':' <addr> : <count> '@' <addr>
<count>, <addr>, <incr> are all 1-4 hex digits
Definition at line 426 of file subbus.c.
References subbus_mread_req::multread_cmd, n_reads, subbus_mread_req::n_reads, new_memory(), and subbus_mread_req::req_len.
Referenced by pack_mread_request(), and pack_mread_requests().
subbus_mread_req* pack_mread_request | ( | int | n_reads, |
const char * | req | ||
) |
Takes a multi-read <addr-list> string and invokes pack_mread().
Definition at line 509 of file subbus.c.
References nl_error, and pack_mread().
subbus_mread_req* pack_mread_requests | ( | unsigned int | addr, |
... | |||
) |
Takes a zero-terminated list of addresses, generates the appropriate text request string and invokes pack_mread().
Definition at line 440 of file subbus.c.
References n_reads, nl_assert, nl_error, and pack_mread().
int read_ack | ( | unsigned short | addr, |
unsigned short * | data | ||
) |
Definition at line 116 of file subbus.c.
Referenced by incoming_sbreq(), read_subbus(), sbrb(), sbrba(), and sbrwa().
unsigned short read_failure | ( | void | ) |
The value reported represents the current state of the indicator lights. As noted in read_switches(), the least significant bit is associated the the main "fail light" located in the cockpit. This light can be lit via set_failure() or the system controller's two minute timeout circuit. In either case, read_failure() will report the actual state of the light.
Definition at line 327 of file subbus.c.
Referenced by incoming_sbreq().
static unsigned short read_special | ( | unsigned short | command | ) | [static] |
Internal function to handle read_switches() and read_failure(), which take no arguments, return unsigned short or zero if the function is not supported.
Definition at line 303 of file subbus.c.
References subbusd_rep_t::data, SBRT_US, SBS_OK, send_to_subbusd(), and subbusd_rep_t::value.
Referenced by read_failure(), and read_switches().
unsigned short read_subbus | ( | unsigned short | addr | ) |
Definition at line 156 of file subbus.c.
References read_ack().
Referenced by sbrb().
unsigned short read_switches | ( | void | ) |
Reads the positions of a dedicated set of system mode switches, usually located on a control panel on the instrument.
Definition at line 314 of file subbus.c.
Referenced by incoming_sbreq().
unsigned short sbrb | ( | unsigned short | addr | ) |
Definition at line 162 of file subbus.c.
Referenced by service_expint().
unsigned short sbrba | ( | unsigned short | addr | ) |
Definition at line 171 of file subbus.c.
References read_ack().
unsigned int sbrwa | ( | unsigned short | addr | ) |
Definition at line 181 of file subbus.c.
References read_ack().
static int send_CSF | ( | unsigned short | command, |
unsigned short | val | ||
) | [static] |
This is an internal function for sending messages with a single unsigned short argument and a simple status return.
Definition at line 242 of file subbus.c.
References subbusd_req_data1::data, nl_error, SBC_SETCMDENBL, SBC_SETCMDSTRB, SBC_SETFAIL, SBRT_NONE, SBS_OK, and send_to_subbusd().
Referenced by set_cmdenbl(), set_cmdstrobe(), and set_failure().
static int send_to_subbusd | ( | unsigned short | command, |
void * | data, | ||
int | data_size, | ||
unsigned short | exp_type | ||
) | [static] |
Definition at line 30 of file subbus.c.
References subbusd_req_hdr_t::command, subbusd_rep_t::hdr, nl_assert, nl_error, subbusd_rep_hdr_t::ret_type, sb_fd, sb_iov, SBRT_CAP, SBRT_MREAD, SBRT_NONE, SBRT_US, and subbusd_rep_hdr_t::status.
Referenced by cache_read(), cache_write(), disarm_sic(), load_subbus(), mread_subbus(), read_ack(), read_special(), send_CSF(), subbus_int_attach(), subbus_int_detach(), subbus_quit(), tick_sic(), and write_ack().
int set_cmdenbl | ( | int | val | ) |
Set cmdenbl value.
Definition at line 263 of file subbus.c.
Referenced by incoming_sbreq().
int set_cmdstrobe | ( | int | val | ) |
Function did not exist at all before version 3.10, so programs intending to use this function should verify that the resident library version is at least 3.10. The feature word can also be checked for support, and that is consistent back to previous versions.
value | 1 turns on cmdstrobe, 0 turns off cmdstrobe |
Definition at line 276 of file subbus.c.
Referenced by incoming_sbreq().
int set_failure | ( | unsigned short | value | ) |
Sets the value of a dedicated set of indicator lights, usually located on a control panel on the instrument and/or in the cockpit of the aircraft. For each bit of the input argument, a non-zero value indicates the associated light should be on.
By convention, the least significant bit is associated with the main "fail light" located in the cockpit on aircraft instruments, indicating that the instrument is not acquiring data.. This light (and the associated bit value on readback) will also be set by the system controller's two minute timeout circuit.
value | Binary-encoded light settings. |
Definition at line 295 of file subbus.c.
Referenced by incoming_sbreq().
int subbus_int_attach | ( | char * | cardID, |
unsigned short | address, | ||
unsigned short | region, | ||
struct sigevent * | event | ||
) |
Definition at line 354 of file subbus.c.
References subbusd_req_data2::address, subbusd_req_data2::cardID, subbusd_req_data2::event, nl_assert, subbusd_req_data2::region, SBC_INTATT, SBRT_US, and send_to_subbusd().
int subbus_int_detach | ( | char * | cardID | ) |
Definition at line 365 of file subbus.c.
References subbusd_req_data3::cardID, nl_assert, SBC_INTDET, SBRT_US, and send_to_subbusd().
int subbus_quit | ( | void | ) |
int tick_sic | ( | void | ) |
Historically, tick_sic() has been associated with two timers. The first is a 2-second timeout that can reboot the system. The second is a 2-minute timeout that lights the main fail light indicating that the instrument is not acquiring data.
It is unclear whether the new syscon_usb will support the reboot timer or rely on a motherboard-specific watchdog timer.
Definition at line 341 of file subbus.c.
Referenced by incoming_sbreq().
int write_ack | ( | unsigned short | addr, |
unsigned short | data | ||
) |
Definition at line 195 of file subbus.c.
Referenced by incoming_sbreq().
char local_subbus_name[SUBBUS_NAME_MAX] [static] |
Definition at line 20 of file subbus.c.
Referenced by get_subbus_name(), and load_subbus().
int sb_fd = -1 [static] |
Definition at line 16 of file subbus.c.
Referenced by get_subbus_name(), load_subbus(), send_to_subbusd(), and subbus_quit().
iov_t sb_iov[3] [static] |
Definition at line 17 of file subbus.c.
Referenced by load_subbus(), and send_to_subbusd().
subbusd_rep_t sb_reply [static] |
subbusd_req_hdr_t sb_req_hdr [static] |
unsigned short subbus_features |
Definition at line 24 of file subbus.c.
Referenced by load_subbus().
unsigned short subbus_subfunction |
Definition at line 23 of file subbus.c.
Referenced by int_init(), int_reset(), and load_subbus().
unsigned short subbus_version = SUBBUS_VERSION |