User talk:MrNuke: Difference between revisions

From coreboot
Jump to navigation Jump to search
No edit summary
mNo edit summary
Line 7: Line 7:




struct Dev
struct Dev
{
{
char* name;
char* name;
 
void (*reset)(void);
void (*reset)(void);
void (*init)(void);
 
void (*shutdown)(void);
void (*init)(void);
Chan* (*attach)(char*); /* tell the device you want to use it */
 
Walkqid* (*walk)(Chan*, Chan*, char**, int); /* walk to a name in the device's managed name space; return a handle */
void (*shutdown)(void);
int (*stat)(Chan*, uchar*, int); // status info
 
Chan* (*open)(Chan*, int); /* get access to a resource in the device name space */
Chan* (*attach)(char*); /* tell the device you want to use it */
void (*close)(Chan*); /* tell it you are done with whatever it is. */
 
long (*read)(Chan*, void*, long, vlong);
Walkqid* (*walk)(Chan*, Chan*, char**, int); /* walk to a name in the device's managed name space; return a handle */
long (*write)(Chan*, void*, long, vlong);
 
void (*power)(int); /* power mgt: power(1) ? on, power (0) ? off */
int (*stat)(Chan*, uchar*, int); // status info
};
 
Chan* (*open)(Chan*, int); /* get access to a resource in the device name space */
 
void (*close)(Chan*); /* tell it you are done with whatever it is. */
 
long (*read)(Chan*, void*, long, vlong);
 
long (*write)(Chan*, void*, long, vlong);
 
void (*power)(int); /* power mgt: power(1) ? on, power (0) ? off */
 
};

Revision as of 22:08, 9 January 2014

Ideas for generic handling of devices

Chan is an IO channel.

This struct is used in Inferno and has been for a long time; so it works. It's also in the opcodes somewhat like what we did for EMMC on ARM.


struct Dev
{
	char*	name;
	void	(*reset)(void);
	void	(*init)(void);
	void	(*shutdown)(void);
	Chan*	(*attach)(char*); /* tell the device you want to use it */
	Walkqid*	(*walk)(Chan*, Chan*, char**, int); /* walk to a name in the device's managed name space; return a handle */
	int	(*stat)(Chan*, uchar*, int); // status info
	Chan*	(*open)(Chan*, int); /* get access to a resource in the device name space */
	void	(*close)(Chan*); /* tell it you are done with whatever it is. */
	long	(*read)(Chan*, void*, long, vlong);
	long	(*write)(Chan*, void*, long, vlong);
	void	(*power)(int);	/* power mgt: power(1) ? on, power (0) ? off */
};