summaryrefslogtreecommitdiff
path: root/demo/demo.h
blob: 28677f6182335638de4df354a9c02dfe4d1a30cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef DEMO_H
#define DEMO_H

#define NUM_CPUS 4

struct lock
{
	volatile unsigned val;
};

struct cpu
{
	unsigned num;
};

/* R12 está reservado por la ABI
 * https://gcc.gnu.org/onlinedocs/gcc/Global-Register-Variables.html
 */
register struct cpu *this_cpu asm("ip");

void spin_init(struct lock *lock);
void spin_lock(struct lock *lock, unsigned *irq_save);
void spin_unlock(struct lock *lock, unsigned irq_save);

void console_init(void);
void print(const char *fmt, ...);
void read_line(char *vuf, unsigned size);

int cpus_ready(void);
void run_cpu(unsigned num);
void run_cpus(unsigned mask);
void halt_cpu(unsigned num);
void halt_cpus(unsigned mask);

int strcmp(const char *s1, const char *s2);
char *strtok_input(char **tokens);

#endif