Statistics
| Branch: | Revision:

scoutos / prex-0.9.0 / sys / include / hal.h @ 03e9c04a

History | View | Annotate | Download (4.08 KB)

1
/*
2
 * Copyright (c) 2005-2009, Kohsuke Ohtani
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
7
 * are met:
8
 * 1. Redistributions of source code must retain the above copyright
9
 *    notice, this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright
11
 *    notice, this list of conditions and the following disclaimer in the
12
 *    documentation and/or other materials provided with the distribution.
13
 * 3. Neither the name of the author nor the names of any co-contributors
14
 *    may be used to endorse or promote products derived from this software
15
 *    without specific prior written permission.
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27
 * SUCH DAMAGE.
28
 */
29

    
30
#ifndef _PREX_HAL_H
31
#define _PREX_HAL_H
32

    
33
#include <types.h>
34
#include <sys/bootinfo.h>
35
#include <context.h>
36
#include <mmu.h>
37

    
38
#define NO_PGD                ((pgd_t)0)        /* non-existent pgd */
39

    
40
/*
41
 * Types for context_set()
42
 */
43
#define CTX_KSTACK        0        /* set kernel mode stack address */
44
#define CTX_KENTRY        1        /* set kernel mode entry address */
45
#define CTX_KARG        2        /* set kernel mode argument */
46
#define CTX_USTACK        3        /* set user mode stack address */
47
#define CTX_UENTRY        4        /* set user mode entry addres */
48
#define CTX_UARG        5        /* set user mode argument */
49

    
50
/*
51
 * page types for mmu_map()
52
 */
53
#define PG_UNMAP        0        /* no page */
54
#define PG_READ                1        /* user - read only */
55
#define PG_WRITE        2        /* user - read/write */
56
#define PG_SYSTEM        3        /* system */
57
#define PG_IOMEM        4        /* system - no cache */
58

    
59
/*
60
 * Virtual/physical address mapping
61
 */
62
struct mmumap
63
{
64
        vaddr_t                virt;                /* virtual address */
65
        paddr_t                phys;                /* physical address */
66
        psize_t                size;                /* size */
67
        int                type;                /* mapping type */
68
};
69

    
70
#define AUTOSIZE        0
71

    
72
/*
73
 * type of virtual memory mappings
74
 */
75
#define VMT_NULL        0
76
#define VMT_RAM                1
77
#define VMT_ROM                2
78
#define VMT_DMA                3
79
#define VMT_IO                4
80

    
81

    
82
/*
83
 * Return value of ISR
84
 */
85
#define INT_DONE        0        /* done */
86
#define INT_ERROR        1        /* error */
87
#define INT_CONTINUE        2        /* continue to IST */
88

    
89
/* No IST for irq_attach() */
90
#define IST_NONE        ((void (*)(void *)) -1)
91

    
92
/*
93
 * Interrupt mode for interrupt_setup()
94
 */
95
#define IMODE_EDGE        0        /* edge trigger */
96
#define IMODE_LEVEL        1        /* level trigger */
97

    
98

    
99
__BEGIN_DECLS
100
void          context_set(context_t, int, register_t);
101
void          context_switch(context_t, context_t);
102
void          context_save(context_t);
103
void          context_restore(context_t);
104
void          context_dump(context_t);
105

    
106
void          mmu_init(struct mmumap *);
107
void          mmu_premap(paddr_t, vaddr_t);
108
pgd_t          mmu_newmap(void);
109
void          mmu_terminate(pgd_t);
110
int          mmu_map(pgd_t, paddr_t, vaddr_t, size_t, int);
111
void          mmu_switch(pgd_t);
112
paddr_t          mmu_extract(pgd_t, vaddr_t, size_t);
113

    
114
int          copyin(const void *, void *, size_t);
115
int          copyout(const void *, void *, size_t);
116
int          copyinstr(const void *, void *, size_t);
117

    
118
int          splhigh(void);
119
int          spl0(void);
120
void          splx(int);
121

    
122
void          syscall_ret(void);
123

    
124
void          interrupt_mask(int);
125
void          interrupt_unmask(int, int);
126
void          interrupt_setup(int, int);
127
void          interrupt_init(void);
128

    
129
void          machine_startup(void);
130
void          machine_idle(void);
131
void          machine_powerdown(int);
132
void          machine_abort(void);
133
void          machine_bootinfo(struct bootinfo **);
134

    
135
void          clock_init(void);
136

    
137
#ifdef DEBUG
138
void          diag_init(void);
139
void          diag_puts(char *);
140
#else
141
#define   diag_init()        ((void)0)
142
#endif
143
__END_DECLS
144

    
145
#endif /* !_PREX_HAL_H */