blob: ef09f091c69754d9e74181cd523c79f21a27b080 [file] [log] [blame]
Norman Jamese7594922015-08-27 14:25:24 -05001#ifndef __OPENBMC_H__
2#define __OPENBMC_H__
3
4#include <stdint.h>
Norman Jamesf10290a2015-10-08 09:03:38 -05005#include <stdio.h>
Norman Jamese7594922015-08-27 14:25:24 -05006
Norman James5e792e32015-10-07 17:36:17 -05007//select which dbus
8#define DBUS_TYPE G_BUS_TYPE_SYSTEM
9
Norman James5d78b4d2015-09-05 13:34:34 -050010// Macros
Patrick Williams0d259e32024-10-04 08:35:52 -040011#define GET_VARIANT(v) g_variant_get_variant(v)
Norman James5d78b4d2015-09-05 13:34:34 -050012#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 James9e6acf92015-09-08 07:00:04 -050014#define GET_VARIANT_B(v) g_variant_get_byte(g_variant_get_variant(v))
Patrick Williams0d259e32024-10-04 08:35:52 -040015#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))
Norman James5d78b4d2015-09-05 13:34:34 -050018#define VARIANT_COMPARE(x,y) g_variant_compare(GET_VARIANT(x),GET_VARIANT(y))
19
Norman James32e74e22015-09-15 21:28:06 -050020#ifdef __arm__
Norman James65a295a2015-09-26 22:21:10 -050021static inline void devmem(void* addr, uint32_t val)
Norman James6f8d0422015-09-14 18:48:00 -050022{
Brad Bishop0c82c602016-04-13 13:36:49 -040023 printf("devmem %p = 0x%08x\n",addr,val);
Norman James6f8d0422015-09-14 18:48:00 -050024 asm volatile("" : : : "memory");
25 *(volatile uint32_t *)addr = val;
26}
Norman James9e9eba12015-11-19 16:05:57 -060027static inline uint32_t devmem_read(void* addr)
28{
29 asm volatile("" : : : "memory");
30 return *(volatile uint32_t *)addr;
31}
Norman James65a295a2015-09-26 22:21:10 -050032//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 James32e74e22015-09-15 21:28:06 -050038#else
Patrick Williams0d259e32024-10-04 08:35:52 -040039static inline void devmem(uint32_t val, uint32_t reg)
Norman James32e74e22015-09-15 21:28:06 -050040{
Patrick Williams0d259e32024-10-04 08:35:52 -040041 (void) val;
42 (void) reg;
Norman James32e74e22015-09-15 21:28:06 -050043}
Norman James9e9eba12015-11-19 16:05:57 -060044static inline uint32_t devmem_read(void* addr)
45{
Patrick Williams0d259e32024-10-04 08:35:52 -040046 (void) addr;
Norman James9e9eba12015-11-19 16:05:57 -060047 return 0;
48}
49
Norman James32e74e22015-09-15 21:28:06 -050050#endif
Norman James5d78b4d2015-09-05 13:34:34 -050051
Norman Jamese7594922015-08-27 14:25:24 -050052typedef struct {
53 gint argc;
Norman James362a80f2015-09-14 14:04:39 -050054 gchar **argv;
Norman Jamesd18f8e42015-10-28 12:44:32 -050055 GMainLoop *loop;
Patrick Williams0d259e32024-10-04 08:35:52 -040056 gpointer user_data;
Norman Jamese7594922015-08-27 14:25:24 -050057
58} cmdline;
59
Norman James5d78b4d2015-09-05 13:34:34 -050060
61
Norman Jamese7594922015-08-27 14:25:24 -050062#endif