xref: /minix3/minix/kernel/arch/earm/include/arch_proto.h (revision 433d6423c39e34ec4b79c950597bb2d236f886be)
1*433d6423SLionel Sambuc 
2*433d6423SLionel Sambuc #ifndef _ARM_PROTO_H
3*433d6423SLionel Sambuc #define _ARM_PROTO_H
4*433d6423SLionel Sambuc 
5*433d6423SLionel Sambuc #include <machine/vm.h>
6*433d6423SLionel Sambuc 
7*433d6423SLionel Sambuc #define K_STACK_SIZE	ARM_PAGE_SIZE
8*433d6423SLionel Sambuc 
9*433d6423SLionel Sambuc 
10*433d6423SLionel Sambuc #ifndef __ASSEMBLY__
11*433d6423SLionel Sambuc 
12*433d6423SLionel Sambuc #include "cpufunc.h"
13*433d6423SLionel Sambuc 
14*433d6423SLionel Sambuc /* klib */
15*433d6423SLionel Sambuc __dead void reset(void);
16*433d6423SLionel Sambuc phys_bytes vir2phys(void *);
17*433d6423SLionel Sambuc vir_bytes phys_memset(phys_bytes ph, u32_t c, phys_bytes bytes);
18*433d6423SLionel Sambuc 
19*433d6423SLionel Sambuc void __switch_address_space(struct proc *p, struct proc **__ptproc);
20*433d6423SLionel Sambuc #define switch_address_space(proc)	\
21*433d6423SLionel Sambuc 	__switch_address_space(proc, get_cpulocal_var_ptr(ptproc))
22*433d6423SLionel Sambuc 
23*433d6423SLionel Sambuc void __copy_msg_from_user_end(void);
24*433d6423SLionel Sambuc void __copy_msg_to_user_end(void);
25*433d6423SLionel Sambuc void __user_copy_msg_pointer_failure(void);
26*433d6423SLionel Sambuc 
27*433d6423SLionel Sambuc /* multiboot.c */
28*433d6423SLionel Sambuc void multiboot_init(void);
29*433d6423SLionel Sambuc 
30*433d6423SLionel Sambuc /* protect.c */
31*433d6423SLionel Sambuc struct tss_s {
32*433d6423SLionel Sambuc   reg_t sp0;                    /* stack pointer to use during interrupt */
33*433d6423SLionel Sambuc } __attribute__((packed));
34*433d6423SLionel Sambuc int tss_init(unsigned cpu, void * kernel_stack);
35*433d6423SLionel Sambuc 
36*433d6423SLionel Sambuc void add_memmap(kinfo_t *cbi, u64_t addr, u64_t len);
37*433d6423SLionel Sambuc phys_bytes alloc_lowest(kinfo_t *cbi, phys_bytes len);
38*433d6423SLionel Sambuc void vm_enable_paging(void);
39*433d6423SLionel Sambuc void cut_memmap(kinfo_t *cbi, phys_bytes start, phys_bytes end);
40*433d6423SLionel Sambuc phys_bytes pg_roundup(phys_bytes b);
41*433d6423SLionel Sambuc void pg_info(reg_t *, u32_t **);
42*433d6423SLionel Sambuc void pg_clear(void);
43*433d6423SLionel Sambuc void pg_identity(kinfo_t *);
44*433d6423SLionel Sambuc phys_bytes pg_load(void);
45*433d6423SLionel Sambuc void pg_map(phys_bytes phys, vir_bytes vaddr, vir_bytes vaddr_end, kinfo_t *cbi);
46*433d6423SLionel Sambuc int pg_mapkernel(void);
47*433d6423SLionel Sambuc void pg_mapproc(struct proc *p, struct boot_image *ip, kinfo_t *cbi);
48*433d6423SLionel Sambuc 
49*433d6423SLionel Sambuc EXTERN void * k_stacks_start;
50*433d6423SLionel Sambuc extern void * k_stacks;
51*433d6423SLionel Sambuc 
52*433d6423SLionel Sambuc #define get_k_stack_top(cpu)	((void *)(((char*)(k_stacks)) \
53*433d6423SLionel Sambuc 					+ 2 * ((cpu) + 1) * K_STACK_SIZE))
54*433d6423SLionel Sambuc 
55*433d6423SLionel Sambuc 
56*433d6423SLionel Sambuc /*
57*433d6423SLionel Sambuc  * Definition of a callback used when a memory map changed it's base address
58*433d6423SLionel Sambuc  */
59*433d6423SLionel Sambuc typedef int (*kern_phys_map_mapped)(vir_bytes id, vir_bytes new_addr );
60*433d6423SLionel Sambuc 
61*433d6423SLionel Sambuc /*
62*433d6423SLionel Sambuc  * struct used internally by memory.c to keep a list of
63*433d6423SLionel Sambuc  * items to map. These should be statically allocated
64*433d6423SLionel Sambuc  * in the individual files and passed as argument.
65*433d6423SLionel Sambuc  * The data doesn't need to be initialized. See omap_serial for
66*433d6423SLionel Sambuc  * and example usage.
67*433d6423SLionel Sambuc  */
68*433d6423SLionel Sambuc typedef struct kern_phys_map{
69*433d6423SLionel Sambuc 	phys_bytes addr; /* The physical address to map */
70*433d6423SLionel Sambuc 	vir_bytes size;  /* The size of the mapping */
71*433d6423SLionel Sambuc 	vir_bytes id;	 /* an id passed to the callback */
72*433d6423SLionel Sambuc 	int vm_flags;	 /* flags to be passed to vm map */
73*433d6423SLionel Sambuc 	kern_phys_map_mapped cb; /* the callback itself */
74*433d6423SLionel Sambuc 	phys_bytes vir; /* The virtual address once remapped */
75*433d6423SLionel Sambuc 	int index; 	/* index */
76*433d6423SLionel Sambuc 	struct kern_phys_map *next; /* pointer to the next */
77*433d6423SLionel Sambuc } kern_phys_map ;
78*433d6423SLionel Sambuc 
79*433d6423SLionel Sambuc 
80*433d6423SLionel Sambuc /*
81*433d6423SLionel Sambuc  * Request an in kernel physical mapping.
82*433d6423SLionel Sambuc  *
83*433d6423SLionel Sambuc  * On ARM many devices are memory mapped and some of these devices
84*433d6423SLionel Sambuc  * are used in the kernel. These device can be things like serial
85*433d6423SLionel Sambuc  * lines, interrupt controller and clocks. The kernel needs to be
86*433d6423SLionel Sambuc  * able to access these devices at the various stages of booting.
87*433d6423SLionel Sambuc  * During startup, until arch_enable_paging is called, it is the
88*433d6423SLionel Sambuc  * kernel whom is controlling the mappings and it often needs to
89*433d6423SLionel Sambuc  * access the memory using a 1:1 mapping between virtual and
90*433d6423SLionel Sambuc  * physical memory.
91*433d6423SLionel Sambuc  *
92*433d6423SLionel Sambuc  * Once processes start to run it is no longer desirable for the
93*433d6423SLionel Sambuc  * kernel to have devices mapped in the middle of the process
94*433d6423SLionel Sambuc  * address space.
95*433d6423SLionel Sambuc  *
96*433d6423SLionel Sambuc  * This method requests the memory manager to map base_address/size
97*433d6423SLionel Sambuc  * in the kernel address space and call back the kernel when this
98*433d6423SLionel Sambuc  * mapping takes effect (after enable_paging).
99*433d6423SLionel Sambuc  *
100*433d6423SLionel Sambuc  * Before the callback is called it is up to the kernel to use it's
101*433d6423SLionel Sambuc  * own addressing. The callback will happen *after* the kernel lost
102*433d6423SLionel Sambuc  * it's initial mapping. It it therefore not safe to use the initial
103*433d6423SLionel Sambuc  * mapping in the callback. It also is not possible to use printf for
104*433d6423SLionel Sambuc  * the same reason.
105*433d6423SLionel Sambuc  */
106*433d6423SLionel Sambuc int kern_req_phys_map( phys_bytes base_address, vir_bytes io_size,
107*433d6423SLionel Sambuc 		   int vm_flags, kern_phys_map * priv,
108*433d6423SLionel Sambuc 		   kern_phys_map_mapped cb, vir_bytes id);
109*433d6423SLionel Sambuc 
110*433d6423SLionel Sambuc /*
111*433d6423SLionel Sambuc  * Request a physical mapping and put the result in the given prt
112*433d6423SLionel Sambuc  * Note that ptr will only be valid once the callback happened.
113*433d6423SLionel Sambuc  */
114*433d6423SLionel Sambuc int kern_phys_map_ptr( phys_bytes base_address, vir_bytes io_size,
115*433d6423SLionel Sambuc 		       int vm_flags, kern_phys_map * priv,
116*433d6423SLionel Sambuc 		       vir_bytes ptr);
117*433d6423SLionel Sambuc 
118*433d6423SLionel Sambuc void arch_ser_init();
119*433d6423SLionel Sambuc 
120*433d6423SLionel Sambuc /* functions defined in architecture-independent kernel source. */
121*433d6423SLionel Sambuc #include "kernel/proto.h"
122*433d6423SLionel Sambuc 
123*433d6423SLionel Sambuc #endif /* __ASSEMBLY__ */
124*433d6423SLionel Sambuc 
125*433d6423SLionel Sambuc #endif
126