xref: /plan9-contrib/sys/include/aml.h (revision ebd848c130c5a90707793ad058d6d29ac82262e7)
1 #pragma	lib	"libaml.a"
2 #pragma	src	"/sys/src/libaml"
3 
4 /*
5  *	b	uchar*	buffer		amllen() returns number of bytes
6  *	s	char*	string		amllen() is strlen()
7  *	n	char*	undefined name	amllen() is strlen()
8  *	i	uvlong*	integer
9  *	p	void**	package		amllen() is # of elements
10  *	r	void*	region
11  *	f	void*	field
12  *	u	void*	bufferfield
13  *	N	void*	name
14  *	R	void*	reference
15  */
16 int		amltag(void *);
17 void*		amlval(void *);
18 uvlong		amlint(void *);
19 int		amllen(void *);
20 
21 void*		amlnew(char tag, int len);
22 
23 void		amlinit(void);
24 void		amlexit(void);
25 
26 int		amlload(uchar *data, int len);
27 void*		amlwalk(void *dot, char *name);
28 int		amleval(void *dot, char *fmt, ...);
29 void		amlenum(void *dot, char *seg, int (*proc)(void *, void *), void *arg);
30 
31 /*
32  * exclude from garbage collection
33  */
34 void		amltake(void *);
35 void		amldrop(void *);
36 
37 void*		amlroot;
38 int		amldebug;
39 
40 #pragma	varargck	type	"V"	void*
41 #pragma	varargck	type	"N"	void*
42 
43 /* to be provided by operating system */
44 extern void*	amlalloc(int);
45 extern void	amlfree(void*);
46 
47 extern void	amldelay(int);	/* microseconds */
48 
49 enum {
50 	MemSpace	= 0x00,
51 	IoSpace		= 0x01,
52 	PcicfgSpace	= 0x02,
53 	EbctlSpace	= 0x03,
54 	SmbusSpace	= 0x04,
55 	CmosSpace	= 0x05,
56 	PcibarSpace	= 0x06,
57 	FixedhwSpace	= 0x08,
58 	IpmiSpace	= 0x07,
59 };
60 
61 typedef struct Amlio Amlio;
62 struct Amlio
63 {
64 	int	space;
65 	uvlong	off;
66 	uvlong	len;
67 	void	*name;
68 	uchar	*va;
69 
70 	void	*aux;
71 	int	(*read)(Amlio *io, void *data, int len, int off);
72 	int	(*write)(Amlio *io, void *data, int len, int off);
73 };
74 
75 extern int	amlmapio(Amlio *io);
76 extern void	amlunmapio(Amlio *io);
77