blob: 576d3a42459e22873903bbf7937a08ef6749df6b [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 James5d78b4d2015-09-05 13:34:34 -05006// Macros
7#define GET_VARIANT(v) g_variant_get_variant(v)
8#define GET_VARIANT_D(v) g_variant_get_double(g_variant_get_variant(v))
9#define GET_VARIANT_U(v) g_variant_get_uint32(g_variant_get_variant(v))
Norman James9e6acf92015-09-08 07:00:04 -050010#define GET_VARIANT_B(v) g_variant_get_byte(g_variant_get_variant(v))
Norman James5d78b4d2015-09-05 13:34:34 -050011#define NEW_VARIANT_D(v) g_variant_new_variant(g_variant_new_double(v))
12#define NEW_VARIANT_U(v) g_variant_new_variant(g_variant_new_uint32(v))
Norman James9e6acf92015-09-08 07:00:04 -050013#define NEW_VARIANT_B(v) g_variant_new_variant(g_variant_new_byte(v))
Norman James5d78b4d2015-09-05 13:34:34 -050014#define VARIANT_COMPARE(x,y) g_variant_compare(GET_VARIANT(x),GET_VARIANT(y))
15
Norman James8abb50c2015-09-16 10:58:16 -050016
17
Norman James32e74e22015-09-15 21:28:06 -050018#ifdef __arm__
Norman James65a295a2015-09-26 22:21:10 -050019static inline void devmem(void* addr, uint32_t val)
Norman James6f8d0422015-09-14 18:48:00 -050020{
Norman James65a295a2015-09-26 22:21:10 -050021 printf("devmem 0x%08x = 0x%08x\n",addr,val);
Norman James6f8d0422015-09-14 18:48:00 -050022 asm volatile("" : : : "memory");
23 *(volatile uint32_t *)addr = val;
24}
Norman James65a295a2015-09-26 22:21:10 -050025//static inline devmem(uint32_t reg, uint32_t val)
26//{
27// printf("devmem 0x%08x = 0x%08x\n",reg,val);
28// //void* r = (void*)reg;
29 // write_reg(reg,val);
30//}
Norman James32e74e22015-09-15 21:28:06 -050031#else
32static inline devmem(uint32_t val, uint32_t reg)
33{
Norman James5d78b4d2015-09-05 13:34:34 -050034
Norman James32e74e22015-09-15 21:28:06 -050035}
36#endif
Norman James5d78b4d2015-09-05 13:34:34 -050037
Norman Jamese7594922015-08-27 14:25:24 -050038typedef struct {
39 gint argc;
Norman James362a80f2015-09-14 14:04:39 -050040 gchar **argv;
41 GMainLoop *loop;
Norman Jamese7594922015-08-27 14:25:24 -050042
43} cmdline;
44
Norman James5d78b4d2015-09-05 13:34:34 -050045
46
Norman Jamese7594922015-08-27 14:25:24 -050047#endif