1 #ifndef __OPENBMC_H__
2 #define __OPENBMC_H__
3 
4 #include <stdint.h>
5 #include <stdio.h>
6 
7 //select which dbus
8 #define DBUS_TYPE  G_BUS_TYPE_SYSTEM
9 
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))
14 #define GET_VARIANT_B(v)       g_variant_get_byte(g_variant_get_variant(v))
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))
17 #define NEW_VARIANT_B(v)       g_variant_new_variant(g_variant_new_byte(v))
18 #define VARIANT_COMPARE(x,y)   g_variant_compare(GET_VARIANT(x),GET_VARIANT(y))
19 
20 #ifdef __arm__
devmem(void * addr,uint32_t val)21 static inline void devmem(void* addr, uint32_t val)
22 {
23 	printf("devmem %p = 0x%08x\n",addr,val);
24         asm volatile("" : : : "memory");
25         *(volatile uint32_t *)addr = val;
26 }
devmem_read(void * addr)27 static inline uint32_t devmem_read(void* addr)
28 {
29         asm volatile("" : : : "memory");
30 	return *(volatile uint32_t *)addr;
31 }
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 //}
38 #else
devmem(uint32_t val,uint32_t reg)39 static inline void devmem(uint32_t val, uint32_t reg)
40 {
41 	(void) val;
42 	(void) reg;
43 }
devmem_read(void * addr)44 static inline uint32_t devmem_read(void* addr)
45 {
46 	(void) addr;
47 	return 0;
48 }
49 
50 #endif
51 
52 typedef struct {
53 	gint argc;
54 	gchar **argv;
55 	GMainLoop *loop;
56 	gpointer user_data;
57 
58 } cmdline;
59 
60 
61 
62 #endif
63