shithub: p9-stm32-example-os

ref: f801657f77f3923ec2388c25bdcb036c8019ba89
dir: /dat.h/

View raw version
/* general constants */
static int hex[16] = { '0', '1', '2', '3', '4', '5', '6', '7',
						'8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
extern	char	etext[];
//extern	char	btext[];
extern	char	edata[];
extern	char	bdata[];
extern	char	end[];

/* clock constants */
#define SYSTICK_LOAD	4200000000UL
//#define SYSTICK_LOAD	24000000UL

/*	GPIO configuration and definitions	*/
typedef
enum
{
	GpioPortA,
	GpioPortB,
	GpioPortC,
	GpioPortD,
} GpioPort;

typedef
struct GpioLine
{
	GpioPort	port;
	char		pin;
	char		mode;
} GpioLine;

/*	USART configuration and definitions	*/
typedef
enum
{
	Usart1,
	Usart2,
} UsartLine;

/*	DMA definitions	*/
#define DMA_BUFSIZE	128

typedef
enum
{
	DmaChan1 = 0,
	DmaChan2,
	DmaChan3,
	DmaChan4,
	DmaChan5,
	DmaChan6,
	DmaChan7,
	DmaChannelCount
} DmaChannel;

/*	synchronization	*/

typedef struct Lock Lock;
typedef struct Label Label;

struct Lock
{
	ulong   key;
	ulong   sr;
	ulong   pc;
	int pri;
};

struct Label
{
	ulong   sp;
	ulong   pc;
};

/*	operating system prep	*/

/*	used typedefs	*/
typedef struct Conf	Conf;
typedef struct Ureg Ureg;
typedef struct Mach Mach;

/*	portdat.h depends on dat.h	*/
#define		ERRMAX		16
#define		KNAMELEN	16

#include	"port/portdat.h"

/*	machine	*/

#define MACHP(n)    (n == 0 ? (Mach*)(MACHADDR) : (Mach*)0)

struct Mach
{
	ulong   splpc;		/* pc of last caller to splhi */
	int     machno;		/* physical id of processor */
	Proc*   proc;		/* current process on this processor */
	ulong   ticks;		/* of the clock since boot time */
	Label   sched;		/* scheduler wakeup */
	int	intr;
	uvlong	fastclock;	/* last sampled value */
	int     cpumhz;
	ulong	cpuhz;
	uvlong	cyclefreq;	/* Frequency of user readable cycle counter */
	u32int	inidle;
	u32int	idleticks;
};

extern Mach *m;
extern Proc *up;

/*	operating system configuration	*/

struct Conf
{
	ulong   nmach;      /* processors */
	ulong   nproc;      /* processes */
	ulong   ialloc;     /* max interrupt time allocation in bytes */
	ulong   topofmem;   /* top addr of memory */
	int     monitor;    /* flag */
};

struct
{
	Lock;
	int machs;          /* bitmap of active CPUs */
	int exiting;        /* shutdown */
} active;