Subversion Repositories HelenOS

Rev

Rev 2697 | Rev 2702 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2697 Rev 2701
Line 1... Line 1...
1
/*
1
/*
2
 * Copyright (c) 2001-2004 Jakub Jermar
2
 * Copyright (c) 2008 Jakub Jermar
3
 * All rights reserved.
3
 * All rights reserved.
4
 *
4
 *
5
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
6
 * modification, are permitted provided that the following conditions
7
 * are met:
7
 * are met:
Line 59... Line 59...
59
    pfn_t start, conf;
59
    pfn_t start, conf;
60
    size_t size;
60
    size_t size;
61
 
61
 
62
    for (i = 0; i < e820counter; i++) {
62
    for (i = 0; i < e820counter; i++) {
63
        if (e820table[i].type == MEMMAP_MEMORY_AVAILABLE) {
63
        if (e820table[i].type == MEMMAP_MEMORY_AVAILABLE) {
64
            start = ADDR2PFN(ALIGN_UP(e820table[i].base_address, FRAME_SIZE));
64
            start = ADDR2PFN(ALIGN_UP(e820table[i].base_address,
-
 
65
                FRAME_SIZE));
65
            size = SIZE2FRAMES(ALIGN_DOWN(e820table[i].size, FRAME_SIZE));
66
            size = SIZE2FRAMES(ALIGN_DOWN(e820table[i].size,
-
 
67
                FRAME_SIZE));
66
            if ((minconf < start) || (minconf >= start + size))
68
            if ((minconf < start) || (minconf >= start + size))
67
                conf = start;
69
                conf = start;
68
            else
70
            else
69
                conf = minconf;
71
                conf = minconf;
70
            zone_create(start, size, conf, 0);
72
            zone_create(start, size, conf, 0);
71
            if (last_frame < ALIGN_UP(e820table[i].base_address + e820table[i].size, FRAME_SIZE))
73
            if (last_frame < ALIGN_UP(e820table[i].base_address +
-
 
74
                e820table[i].size, FRAME_SIZE))
-
 
75
                last_frame =
72
                last_frame = ALIGN_UP(e820table[i].base_address + e820table[i].size, FRAME_SIZE);
76
                    ALIGN_UP(e820table[i].base_address +
-
 
77
                    e820table[i].size, FRAME_SIZE);
73
        }          
78
        }          
74
    }
79
    }
75
}
80
}
76
 
81
 
77
static int cmd_e820mem(cmd_arg_t *argv);
82
static int cmd_e820mem(cmd_arg_t *argv);
Line 80... Line 85...
80
    .description = "List e820 memory.",
85
    .description = "List e820 memory.",
81
    .func = cmd_e820mem,
86
    .func = cmd_e820mem,
82
    .argc = 0
87
    .argc = 0
83
};
88
};
84
 
89
 
85
static char *e820names[] = { "invalid", "available", "reserved",
90
static char *e820names[] = { "invalid", "available", "reserved", "acpi", "nvs",
86
                 "acpi", "nvs", "unusable" };
91
    "unusable" };
87
 
92
 
88
 
93
 
89
static int cmd_e820mem(cmd_arg_t *argv)
94
static int cmd_e820mem(cmd_arg_t *argv)
90
{
95
{
91
    int i;
96
    int i;
Line 94... Line 99...
94
    for (i = 0; i < e820counter; i++) {
99
    for (i = 0; i < e820counter; i++) {
95
        if (e820table[i].type <= MEMMAP_MEMORY_UNUSABLE)
100
        if (e820table[i].type <= MEMMAP_MEMORY_UNUSABLE)
96
            name = e820names[e820table[i].type];
101
            name = e820names[e820table[i].type];
97
        else
102
        else
98
            name = "invalid";
103
            name = "invalid";
99
        printf("%.*p %#.16llXB %s\n",
104
        printf("%.*p %#.16llXB %s\n", sizeof(unative_t) * 2,
100
            sizeof(unative_t) * 2,
-
 
101
               (unative_t) e820table[i].base_address,
105
            (unative_t) e820table[i].base_address,
102
               (uint64_t) e820table[i].size,
106
            (uint64_t) e820table[i].size, name);
103
               name);
-
 
104
    }          
107
    }          
105
    return 0;
108
    return 0;
106
}
109
}
107
 
110
 
108
 
111
 
Line 115... Line 118...
115
        cmd_register(&e820_info);
118
        cmd_register(&e820_info);
116
 
119
 
117
        minconf = 1;
120
        minconf = 1;
118
#ifdef CONFIG_SMP
121
#ifdef CONFIG_SMP
119
        minconf = max(minconf,
122
        minconf = max(minconf,
120
            ADDR2PFN(AP_BOOT_OFFSET + hardcoded_unmapped_ktext_size + hardcoded_unmapped_kdata_size));
123
            ADDR2PFN(AP_BOOT_OFFSET + hardcoded_unmapped_ktext_size +
-
 
124
                hardcoded_unmapped_kdata_size));
121
#endif
125
#endif
122
#ifdef CONFIG_SIMICS_FIX
126
#ifdef CONFIG_SIMICS_FIX
123
        minconf = max(minconf, ADDR2PFN(0x10000));
127
        minconf = max(minconf, ADDR2PFN(0x10000));
124
#endif
128
#endif
125
        init_e820_memory(minconf);
129
        init_e820_memory(minconf);
Line 128... Line 132...
128
        frame_mark_unavailable(0, 1);
132
        frame_mark_unavailable(0, 1);
129
       
133
       
130
#ifdef CONFIG_SMP
134
#ifdef CONFIG_SMP
131
        /* Reserve AP real mode bootstrap memory */
135
        /* Reserve AP real mode bootstrap memory */
132
        frame_mark_unavailable(AP_BOOT_OFFSET >> FRAME_WIDTH,
136
        frame_mark_unavailable(AP_BOOT_OFFSET >> FRAME_WIDTH,
-
 
137
            (hardcoded_unmapped_ktext_size +
133
            (hardcoded_unmapped_ktext_size + hardcoded_unmapped_kdata_size) >> FRAME_WIDTH);
138
            hardcoded_unmapped_kdata_size) >> FRAME_WIDTH);
134
       
139
       
135
#ifdef CONFIG_SIMICS_FIX
140
#ifdef CONFIG_SIMICS_FIX
136
        /* Don't know why, but these addresses help */
141
        /* Don't know why, but these addresses help */
137
        frame_mark_unavailable(0xd000 >> FRAME_WIDTH, 3);
142
        frame_mark_unavailable(0xd000 >> FRAME_WIDTH, 3);
138
#endif
143
#endif