Norman James | e759492 | 2015-08-27 14:25:24 -0500 | [diff] [blame] | 1 | #ifndef __OPENBMC_H__ |
| 2 | #define __OPENBMC_H__ |
| 3 | |
| 4 | #include <stdint.h> |
Norman James | f10290a | 2015-10-08 09:03:38 -0500 | [diff] [blame] | 5 | #include <stdio.h> |
Norman James | e759492 | 2015-08-27 14:25:24 -0500 | [diff] [blame] | 6 | |
Norman James | 5e792e3 | 2015-10-07 17:36:17 -0500 | [diff] [blame] | 7 | //select which dbus |
| 8 | #define DBUS_TYPE G_BUS_TYPE_SYSTEM |
| 9 | |
Norman James | 5d78b4d | 2015-09-05 13:34:34 -0500 | [diff] [blame] | 10 | // Macros |
| 11 | #define GET_VARIANT(v) g_variant_get_variant(v) |
| 12 | #define GET_VARIANT_D(v) g_variant_get_double(g_variant_get_variant(v)) |
| 13 | #define GET_VARIANT_U(v) g_variant_get_uint32(g_variant_get_variant(v)) |
Norman James | 9e6acf9 | 2015-09-08 07:00:04 -0500 | [diff] [blame] | 14 | #define GET_VARIANT_B(v) g_variant_get_byte(g_variant_get_variant(v)) |
Norman James | 5d78b4d | 2015-09-05 13:34:34 -0500 | [diff] [blame] | 15 | #define NEW_VARIANT_D(v) g_variant_new_variant(g_variant_new_double(v)) |
| 16 | #define NEW_VARIANT_U(v) g_variant_new_variant(g_variant_new_uint32(v)) |
Norman James | 9e6acf9 | 2015-09-08 07:00:04 -0500 | [diff] [blame] | 17 | #define NEW_VARIANT_B(v) g_variant_new_variant(g_variant_new_byte(v)) |
Norman James | 5d78b4d | 2015-09-05 13:34:34 -0500 | [diff] [blame] | 18 | #define VARIANT_COMPARE(x,y) g_variant_compare(GET_VARIANT(x),GET_VARIANT(y)) |
| 19 | |
Norman James | 32e74e2 | 2015-09-15 21:28:06 -0500 | [diff] [blame] | 20 | #ifdef __arm__ |
Norman James | 65a295a | 2015-09-26 22:21:10 -0500 | [diff] [blame] | 21 | static inline void devmem(void* addr, uint32_t val) |
Norman James | 6f8d042 | 2015-09-14 18:48:00 -0500 | [diff] [blame] | 22 | { |
Brad Bishop | 0c82c60 | 2016-04-13 13:36:49 -0400 | [diff] [blame] | 23 | printf("devmem %p = 0x%08x\n",addr,val); |
Norman James | 6f8d042 | 2015-09-14 18:48:00 -0500 | [diff] [blame] | 24 | asm volatile("" : : : "memory"); |
| 25 | *(volatile uint32_t *)addr = val; |
| 26 | } |
Norman James | 9e9eba1 | 2015-11-19 16:05:57 -0600 | [diff] [blame] | 27 | static inline uint32_t devmem_read(void* addr) |
| 28 | { |
| 29 | asm volatile("" : : : "memory"); |
| 30 | return *(volatile uint32_t *)addr; |
| 31 | } |
Norman James | 65a295a | 2015-09-26 22:21:10 -0500 | [diff] [blame] | 32 | //static inline devmem(uint32_t reg, uint32_t val) |
| 33 | //{ |
| 34 | // printf("devmem 0x%08x = 0x%08x\n",reg,val); |
| 35 | // //void* r = (void*)reg; |
| 36 | // write_reg(reg,val); |
| 37 | //} |
Norman James | 32e74e2 | 2015-09-15 21:28:06 -0500 | [diff] [blame] | 38 | #else |
| 39 | static inline devmem(uint32_t val, uint32_t reg) |
| 40 | { |
Norman James | 32e74e2 | 2015-09-15 21:28:06 -0500 | [diff] [blame] | 41 | } |
Norman James | 9e9eba1 | 2015-11-19 16:05:57 -0600 | [diff] [blame] | 42 | static inline uint32_t devmem_read(void* addr) |
| 43 | { |
| 44 | return 0; |
| 45 | } |
| 46 | |
Norman James | 32e74e2 | 2015-09-15 21:28:06 -0500 | [diff] [blame] | 47 | #endif |
Norman James | 5d78b4d | 2015-09-05 13:34:34 -0500 | [diff] [blame] | 48 | |
Norman James | e759492 | 2015-08-27 14:25:24 -0500 | [diff] [blame] | 49 | typedef struct { |
| 50 | gint argc; |
Norman James | 362a80f | 2015-09-14 14:04:39 -0500 | [diff] [blame] | 51 | gchar **argv; |
Norman James | d18f8e4 | 2015-10-28 12:44:32 -0500 | [diff] [blame] | 52 | GMainLoop *loop; |
| 53 | gpointer user_data; |
Norman James | e759492 | 2015-08-27 14:25:24 -0500 | [diff] [blame] | 54 | |
| 55 | } cmdline; |
| 56 | |
Norman James | 5d78b4d | 2015-09-05 13:34:34 -0500 | [diff] [blame] | 57 | |
| 58 | |
Norman James | e759492 | 2015-08-27 14:25:24 -0500 | [diff] [blame] | 59 | #endif |