+static uint8_t send_keypress = 0;
+static uint32_t platform_res, rres;
+
+uint8_t cdtv_dmac_reg_idx_read();
+void cdtv_dmac_reg_idx_write(uint8_t value);
+uint32_t cdtv_dmac_read(uint32_t address, uint8_t type);
+void cdtv_dmac_write(uint32_t address, uint32_t value, uint8_t type);
+
+unsigned int garbage = 0;
+
+static inline void inline_write_16(unsigned int address, unsigned int data) {
+ *(gpio + 0) = GPFSEL0_OUTPUT;
+ *(gpio + 1) = GPFSEL1_OUTPUT;
+ *(gpio + 2) = GPFSEL2_OUTPUT;
+
+ *(gpio + 7) = ((data & 0xffff) << 8) | (REG_DATA << PIN_A0);
+ *(gpio + 7) = 1 << PIN_WR;
+ *(gpio + 10) = 1 << PIN_WR;
+ *(gpio + 10) = 0xffffec;
+
+ *(gpio + 7) = ((address & 0xffff) << 8) | (REG_ADDR_LO << PIN_A0);
+ *(gpio + 7) = 1 << PIN_WR;
+ *(gpio + 10) = 1 << PIN_WR;
+ *(gpio + 10) = 0xffffec;
+
+ *(gpio + 7) = ((0x0000 | (address >> 16)) << 8) | (REG_ADDR_HI << PIN_A0);
+ *(gpio + 7) = 1 << PIN_WR;
+ *(gpio + 10) = 1 << PIN_WR;
+ *(gpio + 10) = 0xffffec;
+
+ *(gpio + 0) = GPFSEL0_INPUT;
+ *(gpio + 1) = GPFSEL1_INPUT;
+ *(gpio + 2) = GPFSEL2_INPUT;
+
+ while (*(gpio + 13) & (1 << PIN_TXN_IN_PROGRESS)) {}
+ NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP
+}
+
+static inline void inline_write_8(unsigned int address, unsigned int data) {
+ if ((address & 1) == 0)
+ data = data + (data << 8); // EVEN, A0=0,UDS
+ else
+ data = data & 0xff; // ODD , A0=1,LDS
+
+ *(gpio + 0) = GPFSEL0_OUTPUT;
+ *(gpio + 1) = GPFSEL1_OUTPUT;
+ *(gpio + 2) = GPFSEL2_OUTPUT;
+
+ *(gpio + 7) = ((data & 0xffff) << 8) | (REG_DATA << PIN_A0);
+ *(gpio + 7) = 1 << PIN_WR;
+ *(gpio + 10) = 1 << PIN_WR;
+ *(gpio + 10) = 0xffffec;
+
+ *(gpio + 7) = ((address & 0xffff) << 8) | (REG_ADDR_LO << PIN_A0);
+ *(gpio + 7) = 1 << PIN_WR;
+ *(gpio + 10) = 1 << PIN_WR;
+ *(gpio + 10) = 0xffffec;
+
+ *(gpio + 7) = ((0x0100 | (address >> 16)) << 8) | (REG_ADDR_HI << PIN_A0);
+ *(gpio + 7) = 1 << PIN_WR;
+ *(gpio + 10) = 1 << PIN_WR;
+ *(gpio + 10) = 0xffffec;
+
+ *(gpio + 0) = GPFSEL0_INPUT;
+ *(gpio + 1) = GPFSEL1_INPUT;
+ *(gpio + 2) = GPFSEL2_INPUT;
+
+ while (*(gpio + 13) & (1 << PIN_TXN_IN_PROGRESS)) {}
+ NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP NOP
+}
+
+static inline void inline_write_32(unsigned int address, unsigned int value) {
+ inline_write_16(address, value >> 16);
+ inline_write_16(address + 2, value);
+}
+
+static inline unsigned int inline_read_16(unsigned int address) {
+ *(gpio + 0) = GPFSEL0_OUTPUT;
+ *(gpio + 1) = GPFSEL1_OUTPUT;
+ *(gpio + 2) = GPFSEL2_OUTPUT;
+
+ *(gpio + 7) = ((address & 0xffff) << 8) | (REG_ADDR_LO << PIN_A0);
+ *(gpio + 7) = 1 << PIN_WR;
+ *(gpio + 10) = 1 << PIN_WR;
+ *(gpio + 10) = 0xffffec;
+
+ *(gpio + 7) = ((0x0200 | (address >> 16)) << 8) | (REG_ADDR_HI << PIN_A0);
+ *(gpio + 7) = 1 << PIN_WR;
+ *(gpio + 10) = 1 << PIN_WR;
+ *(gpio + 10) = 0xffffec;
+
+ *(gpio + 0) = GPFSEL0_INPUT;
+ *(gpio + 1) = GPFSEL1_INPUT;
+ *(gpio + 2) = GPFSEL2_INPUT;
+
+ *(gpio + 7) = (REG_DATA << PIN_A0);
+ *(gpio + 7) = 1 << PIN_RD;
+
+ while (*(gpio + 13) & (1 << PIN_TXN_IN_PROGRESS)) {}
+ unsigned int value = *(gpio + 13);
+
+ *(gpio + 10) = 0xffffec;
+
+ return (value >> 8) & 0xffff;
+}
+
+static inline unsigned int inline_read_8(unsigned int address) {
+ *(gpio + 0) = GPFSEL0_OUTPUT;
+ *(gpio + 1) = GPFSEL1_OUTPUT;
+ *(gpio + 2) = GPFSEL2_OUTPUT;
+
+ *(gpio + 7) = ((address & 0xffff) << 8) | (REG_ADDR_LO << PIN_A0);
+ *(gpio + 7) = 1 << PIN_WR;
+ *(gpio + 10) = 1 << PIN_WR;
+ *(gpio + 10) = 0xffffec;
+
+ *(gpio + 7) = ((0x0300 | (address >> 16)) << 8) | (REG_ADDR_HI << PIN_A0);
+ *(gpio + 7) = 1 << PIN_WR;
+ *(gpio + 10) = 1 << PIN_WR;
+ *(gpio + 10) = 0xffffec;
+
+ *(gpio + 0) = GPFSEL0_INPUT;
+ *(gpio + 1) = GPFSEL1_INPUT;
+ *(gpio + 2) = GPFSEL2_INPUT;
+
+ *(gpio + 7) = (REG_DATA << PIN_A0);
+ *(gpio + 7) = 1 << PIN_RD;
+
+ while (*(gpio + 13) & (1 << PIN_TXN_IN_PROGRESS)) {}
+ unsigned int value = *(gpio + 13);
+
+ *(gpio + 10) = 0xffffec;