blob: bb6a17b8b6d232d286eeba6d08713bbe30e07baf [file] [log] [blame]
Corey Tabaka84697242009-03-26 02:32:01 -04001/*
2 * Copyright (c) 2009 Corey Tabaka
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files
6 * (the "Software"), to deal in the Software without restriction,
7 * including without limitation the rights to use, copy, modify, merge,
8 * publish, distribute, sublicense, and/or sell copies of the Software,
9 * and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23#include <debug.h>
24#include <arch.h>
25#include <arch/ops.h>
26#include <arch/x86.h>
27#include <arch/x86/mmu.h>
28#include <arch/x86/descriptor.h>
29#include <platform.h>
30#include <sys/types.h>
31#include <string.h>
32
33static tss_t system_tss;
34
35void arch_early_init(void)
36{
37 x86_mmu_init();
38
39 platform_init_mmu_mappings();
40
41 /* enable caches here for now */
42 clear_in_cr0(X86_CR0_NW | X86_CR0_CD);
43
44 memset(&system_tss, 0, sizeof(tss_t));
45
46 system_tss.esp0 = 0;
47 system_tss.ss0 = DATA_SELECTOR;
48 system_tss.ss1 = 0;
49 system_tss.ss2 = 0;
50 system_tss.eflags = 0x00003002;
51 system_tss.bitmap = offsetof(tss_t, tss_bitmap);
52 system_tss.trace = 1; // trap on hardware task switch
53
54 set_global_desc(TSS_SELECTOR, &system_tss, sizeof(tss_t), 1, 0, 0, SEG_TYPE_TSS, 0, 0);
55
56 x86_ltr(TSS_SELECTOR);
57}
58
59void arch_init(void)
60{
61}
62
Ajay Dudanica0b6a22011-05-18 19:48:32 -070063uint32_t arch_cycle_count(void)
64{
65 uint32_t timestamp;
66 rdtscl(timestamp);
67
68 return timestamp;
69}
70