blob: 07546e2db5159b0b964839d8529e2abf10733e15 [file] [log] [blame]
Norman Jamese7594922015-08-27 14:25:24 -05001#ifndef __OPENBMC_H__
2#define __OPENBMC_H__
3
4#include <stdint.h>
5
Norman James5e792e32015-10-07 17:36:17 -05006//select which dbus
7#define DBUS_TYPE G_BUS_TYPE_SYSTEM
8
Norman James5d78b4d2015-09-05 13:34:34 -05009// Macros
10#define GET_VARIANT(v) g_variant_get_variant(v)
11#define GET_VARIANT_D(v) g_variant_get_double(g_variant_get_variant(v))
12#define GET_VARIANT_U(v) g_variant_get_uint32(g_variant_get_variant(v))
Norman James9e6acf92015-09-08 07:00:04 -050013#define GET_VARIANT_B(v) g_variant_get_byte(g_variant_get_variant(v))
Norman James5d78b4d2015-09-05 13:34:34 -050014#define NEW_VARIANT_D(v) g_variant_new_variant(g_variant_new_double(v))
15#define NEW_VARIANT_U(v) g_variant_new_variant(g_variant_new_uint32(v))
Norman James9e6acf92015-09-08 07:00:04 -050016#define NEW_VARIANT_B(v) g_variant_new_variant(g_variant_new_byte(v))
Norman James5d78b4d2015-09-05 13:34:34 -050017#define VARIANT_COMPARE(x,y) g_variant_compare(GET_VARIANT(x),GET_VARIANT(y))
18
Norman James32e74e22015-09-15 21:28:06 -050019#ifdef __arm__
Norman James65a295a2015-09-26 22:21:10 -050020static inline void devmem(void* addr, uint32_t val)
Norman James6f8d0422015-09-14 18:48:00 -050021{
Norman James65a295a2015-09-26 22:21:10 -050022 printf("devmem 0x%08x = 0x%08x\n",addr,val);
Norman James6f8d0422015-09-14 18:48:00 -050023 asm volatile("" : : : "memory");
24 *(volatile uint32_t *)addr = val;
25}
Norman James65a295a2015-09-26 22:21:10 -050026//static inline devmem(uint32_t reg, uint32_t val)
27//{
28// printf("devmem 0x%08x = 0x%08x\n",reg,val);
29// //void* r = (void*)reg;
30 // write_reg(reg,val);
31//}
Norman James32e74e22015-09-15 21:28:06 -050032#else
33static inline devmem(uint32_t val, uint32_t reg)
34{
Norman James5d78b4d2015-09-05 13:34:34 -050035
Norman James32e74e22015-09-15 21:28:06 -050036}
37#endif
Norman James5d78b4d2015-09-05 13:34:34 -050038
Norman Jamese7594922015-08-27 14:25:24 -050039typedef struct {
40 gint argc;
Norman James362a80f2015-09-14 14:04:39 -050041 gchar **argv;
42 GMainLoop *loop;
Norman Jamese7594922015-08-27 14:25:24 -050043
44} cmdline;
45
Norman James5d78b4d2015-09-05 13:34:34 -050046
47
Norman Jamese7594922015-08-27 14:25:24 -050048#endif