#ifndef __KERNEL_H__ #define __KERNEL_H__ #include "util/minimal_io.h" #include #include class Kernel { private: Kernel(); Kernel(const Kernel &orig); ~Kernel(); Kernel &operator=(const Kernel &orig); bool initialized; public: enum special_devices { SYS_MAPPED = 0, UBLOX, GS_LINK, FLASHROM, ADC, FAT_FILE, USB_UART, OBCLED, NUL }; struct SystemIO : public MinimalIO { int ref_count; unsigned int receive(char *buf, const unsigned int &buf_size); unsigned int transmit(const char *buf, const unsigned int &buf_size); bool ioctl(const void *params); SystemIO(); virtual ~SystemIO(); }; class IO : public MinimalIO { private: SystemIO *delegatee; public: unsigned int receive(char *buf, const unsigned int &buf_size); unsigned int transmit(const char *buf, const unsigned int &buf_size); bool ioctl(const void *params); IO(); IO(SystemIO *io); IO(const IO &orig); IO &operator=(const IO &rhs); ~IO(); }; void initialize(); static Kernel &get_instance(); IO open(const special_devices &id, const void *params = NULL); void notify_itow(const Uint32 &latest_itow_ms); void notify_satellites(const Uint8 &latest_satellites); Uint32 itow_ms() const; enum mbx_devices { MBX_ADC = 0, MBX_SERVO_WRITE, MBX_SERVO_READ, MBX_PITOT, MBX_MAG, MBX_TU_INFO, MBX_MU_INFO, MBX_MAG_INFO, MBX_NAV_INFO, MBX_GC_INFO, MBX_NUL }; private: MBX_Handle mbx_handles[MBX_NUL]; public: struct msg_adc_t { Uint32 time_ms; Uint32 ch[8]; }; struct msg_servo_write_t { Uint32 time_ms; Uint16 ch[8]; }; struct msg_servo_read_t { Uint32 time_ms; Uint16 ch_in[8]; Uint16 ch_out[8]; }; struct msg_pitot_t { Uint32 time_ms; Uint8 raw_buf[8]; }; struct msg_mag_t { Uint32 time_ms; Uint8 raw_buf[6]; }; MBX_Handle mbx(const mbx_devices &id) const; }; #endif /* __KERNEL_H__ */