Subversion Repositories HelenOS

Rev

Rev 2787 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2787 Rev 4377
Line 24... Line 24...
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
27
 */
28
 
28
 
29
/** @addtogroup ia32   
29
/** @addtogroup ia32
30
 * @{
30
 * @{
31
 */
31
 */
32
/** @file
32
/** @file
33
 */
33
 */
34
 
34
 
35
#ifndef KERN_ia32_PM_H_
35
#ifndef KERN_ia32_PM_H_
36
#define KERN_ia32_PM_H_
36
#define KERN_ia32_PM_H_
37
 
37
 
38
#define IDT_ITEMS   64  
38
#define IDT_ITEMS  64
39
#define GDT_ITEMS   7
39
#define GDT_ITEMS  7
40
 
40
 
41
#define VESA_INIT_SEGMENT 0x8000
-
 
42
 
-
 
43
#define NULL_DES    0
41
#define NULL_DES   0
44
#define KTEXT_DES   1
42
#define KTEXT_DES  1
45
#define KDATA_DES   2
43
#define KDATA_DES  2
46
#define UTEXT_DES   3
44
#define UTEXT_DES  3
47
#define UDATA_DES   4
45
#define UDATA_DES  4
48
#define TSS_DES     5
46
#define TSS_DES    5
49
#define TLS_DES     6 /* Pointer to Thread-Local-Storage data */
47
#define TLS_DES    6  /* Pointer to Thread-Local-Storage data */
50
 
48
 
51
#ifdef CONFIG_FB
49
#ifdef CONFIG_FB
52
 
50
 
53
#define VESA_INIT_SEGMENT 0x8000
51
#define VESA_INIT_SEGMENT  0x8000
54
#define VESA_INIT_DES 7
52
#define VESA_INIT_DES      7
-
 
53
#define KTEXT32_DES        KTEXT_DES
-
 
54
 
55
#undef GDT_ITEMS
55
#undef GDT_ITEMS
56
#define GDT_ITEMS 8
56
#define GDT_ITEMS  8
57
 
57
 
58
#endif /* CONFIG_FB */
58
#endif /* CONFIG_FB */
59
 
59
 
-
 
60
#define gdtselector(des)  ((des) << 3)
60
 
61
 
61
#define selector(des)   ((des) << 3)
-
 
62
 
-
 
63
#define PL_KERNEL   0
62
#define PL_KERNEL  0
64
#define PL_USER     3
63
#define PL_USER    3
65
 
64
 
66
#define AR_PRESENT  (1 << 7)
65
#define AR_PRESENT    (1 << 7)
67
#define AR_DATA     (2 << 3)
66
#define AR_DATA       (2 << 3)
68
#define AR_CODE     (3 << 3)
67
#define AR_CODE       (3 << 3)
69
#define AR_WRITABLE (1 << 1)
68
#define AR_WRITABLE   (1 << 1)
70
#define AR_INTERRUPT    (0xe)
69
#define AR_INTERRUPT  (0x0e)
71
#define AR_TSS      (0x9)
70
#define AR_TSS        (0x09)
72
 
71
 
73
#define DPL_KERNEL  (PL_KERNEL << 5)
72
#define DPL_KERNEL  (PL_KERNEL << 5)
74
#define DPL_USER    (PL_USER << 5)
73
#define DPL_USER    (PL_USER << 5)
75
 
74
 
76
#define TSS_BASIC_SIZE  104
75
#define TSS_BASIC_SIZE  104
77
#define TSS_IOMAP_SIZE  (16 * 1024 + 1) /* 16K for bitmap + 1 terminating byte for convenience */
76
#define TSS_IOMAP_SIZE  (16 * 1024 + 1)  /* 16K for bitmap + 1 terminating byte for convenience */
78
 
77
 
79
#define IO_PORTS    (64 * 1024)
78
#define IO_PORTS  (64 * 1024)
80
 
79
 
81
#ifndef __ASM__
80
#ifndef __ASM__
82
 
81
 
83
#include <arch/types.h>
82
#include <arch/types.h>
84
#include <arch/context.h>
83
#include <arch/context.h>
85
 
84
 
86
struct ptr_16_32 {
85
typedef struct {
87
    uint16_t limit;
86
    uint16_t limit;
88
    uint32_t base;
87
    uint32_t base;
89
} __attribute__ ((packed));
88
} __attribute__ ((packed)) ptr_16_32_t;
90
typedef struct ptr_16_32 ptr_16_32_t;
-
 
91
 
89
 
92
struct descriptor {
90
typedef struct {
93
    unsigned limit_0_15: 16;
91
    unsigned limit_0_15: 16;
94
    unsigned base_0_15: 16;
92
    unsigned base_0_15: 16;
95
    unsigned base_16_23: 8;
93
    unsigned base_16_23: 8;
96
    unsigned access: 8;
94
    unsigned access: 8;
97
    unsigned limit_16_19: 4;
95
    unsigned limit_16_19: 4;
98
    unsigned available: 1;
96
    unsigned available: 1;
99
    unsigned unused: 1;
97
    unsigned unused: 1;
100
    unsigned special: 1;
98
    unsigned special: 1;
101
    unsigned granularity : 1;
99
    unsigned granularity : 1;
102
    unsigned base_24_31: 8;
100
    unsigned base_24_31: 8;
103
} __attribute__ ((packed));
101
} __attribute__ ((packed)) descriptor_t;
104
typedef struct descriptor  descriptor_t;
-
 
105
 
102
 
106
struct idescriptor {
103
typedef struct {
107
    unsigned offset_0_15: 16;
104
    unsigned offset_0_15: 16;
108
    unsigned selector: 16;
105
    unsigned selector: 16;
109
    unsigned unused: 8;
106
    unsigned unused: 8;
110
    unsigned access: 8;
107
    unsigned access: 8;
111
    unsigned offset_16_31: 16;
108
    unsigned offset_16_31: 16;
112
} __attribute__ ((packed));
109
} __attribute__ ((packed)) idescriptor_t;
113
typedef struct idescriptor idescriptor_t;
-
 
114
 
110
 
115
struct tss {
111
typedef struct {
116
    uint16_t link;
112
    uint16_t link;
117
    unsigned : 16;
113
    unsigned : 16;
118
    uint32_t esp0;
114
    uint32_t esp0;
119
    uint16_t ss0;
115
    uint16_t ss0;
120
    unsigned : 16;
116
    unsigned : 16;
Line 150... Line 146...
150
    uint16_t ldtr;
146
    uint16_t ldtr;
151
    unsigned : 16;
147
    unsigned : 16;
152
    unsigned : 16;
148
    unsigned : 16;
153
    uint16_t iomap_base;
149
    uint16_t iomap_base;
154
    uint8_t iomap[TSS_IOMAP_SIZE];
150
    uint8_t iomap[TSS_IOMAP_SIZE];
155
} __attribute__ ((packed));
151
} __attribute__ ((packed)) tss_t;
156
typedef struct tss tss_t;
-
 
157
 
152
 
158
extern ptr_16_32_t gdtr;
153
extern ptr_16_32_t gdtr;
159
extern ptr_16_32_t bootstrap_gdtr;
154
extern ptr_16_32_t bootstrap_gdtr;
160
extern ptr_16_32_t protected_ap_gdtr;
155
extern ptr_16_32_t protected_ap_gdtr;
161
extern struct tss *tss_p;
156
extern tss_t *tss_p;
162
 
157
 
163
extern descriptor_t gdt[];
158
extern descriptor_t gdt[];
164
 
159
 
165
extern void pm_init(void);
160
extern void pm_init(void);
166
 
161