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