Subversion Repositories HelenOS

Rev

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

Rev 2071 Rev 2141
Line 71... Line 71...
71
        /*
71
        /*
72
         * Copy locked DTLB entries from the BSP.
72
         * Copy locked DTLB entries from the BSP.
73
         */    
73
         */    
74
        for (i = 0; i < bsp_locked_dtlb_entries; i++) {
74
        for (i = 0; i < bsp_locked_dtlb_entries; i++) {
75
            dtlb_insert_mapping(bsp_locked_dtlb_entry[i].virt_page,
75
            dtlb_insert_mapping(bsp_locked_dtlb_entry[i].virt_page,
76
                bsp_locked_dtlb_entry[i].phys_page,
76
                bsp_locked_dtlb_entry[i].phys_page,
77
                bsp_locked_dtlb_entry[i].pagesize_code, true,
77
                bsp_locked_dtlb_entry[i].pagesize_code, true,
78
                false);
78
                false);
79
        }
79
        }
80
#endif  
80
#endif  
81
 
81
 
82
    }
82
    }
83
}
83
}
Line 105... Line 105...
105
    struct {
105
    struct {
106
        int pagesize_code;
106
        int pagesize_code;
107
        size_t increment;
107
        size_t increment;
108
        count_t count;
108
        count_t count;
109
    } sizemap[] = {
109
    } sizemap[] = {
110
        { PAGESIZE_8K, 0, 1 },          /* 8K */
110
        { PAGESIZE_8K, 0, 1 },              /* 8K */
111
        { PAGESIZE_8K, PAGE_SIZE, 2 },      /* 16K */
111
        { PAGESIZE_8K, MMU_PAGE_SIZE, 2 },      /* 16K */
112
        { PAGESIZE_8K, PAGE_SIZE, 4 },      /* 32K */
112
        { PAGESIZE_8K, MMU_PAGE_SIZE, 4 },      /* 32K */
113
        { PAGESIZE_64K, 0, 1},          /* 64K */
113
        { PAGESIZE_64K, 0, 1},              /* 64K */
114
        { PAGESIZE_64K, 8 * PAGE_SIZE, 2 }, /* 128K */
114
        { PAGESIZE_64K, 8 * MMU_PAGE_SIZE, 2 },     /* 128K */
115
        { PAGESIZE_64K, 8 * PAGE_SIZE, 4 }, /* 256K */
115
        { PAGESIZE_64K, 8 * MMU_PAGE_SIZE, 4 },     /* 256K */
116
        { PAGESIZE_512K, 0, 1 },        /* 512K */
116
        { PAGESIZE_512K, 0, 1 },            /* 512K */
117
        { PAGESIZE_512K, 64 * PAGE_SIZE, 2 },   /* 1M */
117
        { PAGESIZE_512K, 64 * MMU_PAGE_SIZE, 2 },   /* 1M */
118
        { PAGESIZE_512K, 64 * PAGE_SIZE, 4 },   /* 2M */
118
        { PAGESIZE_512K, 64 * MMU_PAGE_SIZE, 4 },   /* 2M */
119
        { PAGESIZE_4M, 0, 1 },          /* 4M */
119
        { PAGESIZE_4M, 0, 1 },              /* 4M */
120
        { PAGESIZE_4M, 512 * PAGE_SIZE, 2 } /* 8M */
120
        { PAGESIZE_4M, 512 * MMU_PAGE_SIZE, 2 }     /* 8M */
121
    };
121
    };
122
   
122
   
123
    ASSERT(ALIGN_UP(physaddr, PAGE_SIZE) == physaddr);
123
    ASSERT(ALIGN_UP(physaddr, MMU_PAGE_SIZE) == physaddr);
124
    ASSERT(size <= 8 * 1024 * 1024);
124
    ASSERT(size <= 8 * 1024 * 1024);
125
   
125
   
126
    if (size <= FRAME_SIZE)
126
    if (size <= MMU_FRAME_SIZE)
127
        order = 0;
127
        order = 0;
128
    else
128
    else
129
        order = (fnzb64(size - 1) + 1) - FRAME_WIDTH;
129
        order = (fnzb64(size - 1) + 1) - MMU_FRAME_WIDTH;
130
 
130
 
131
    /*
131
    /*
132
     * Use virtual addresses that are beyond the limit of physical memory.
132
     * Use virtual addresses that are beyond the limit of physical memory.
133
     * Thus, the physical address space will not be wasted by holes created
133
     * Thus, the physical address space will not be wasted by holes created
134
     * by frame_alloc().
134
     * by frame_alloc().
135
     */
135
     */
136
    ASSERT(PA2KA(last_frame));
136
    ASSERT(PA2KA(last_frame));
137
    uintptr_t virtaddr = ALIGN_UP(PA2KA(last_frame), 1 << (order + FRAME_WIDTH));
137
    uintptr_t virtaddr = ALIGN_UP(PA2KA(last_frame),
-
 
138
        1 << (order + FRAME_WIDTH));
138
    last_frame = ALIGN_UP(KA2PA(virtaddr) + size, 1 << (order + FRAME_WIDTH));
139
    last_frame = ALIGN_UP(KA2PA(virtaddr) + size,
-
 
140
        1 << (order + FRAME_WIDTH));
139
   
141
   
140
    for (i = 0; i < sizemap[order].count; i++) {
142
    for (i = 0; i < sizemap[order].count; i++) {
141
        /*
143
        /*
142
         * First, insert the mapping into DTLB.
144
         * First, insert the mapping into DTLB.
143
         */
145
         */
144
        dtlb_insert_mapping(virtaddr + i * sizemap[order].increment,
146
        dtlb_insert_mapping(virtaddr + i * sizemap[order].increment,
145
            physaddr + i * sizemap[order].increment,
147
            physaddr + i * sizemap[order].increment,
146
            sizemap[order].pagesize_code, true, false);
148
            sizemap[order].pagesize_code, true, false);
147
   
149
   
148
#ifdef CONFIG_SMP   
150
#ifdef CONFIG_SMP   
149
        /*
151
        /*
150
         * Second, save the information about the mapping for APs.
152
         * Second, save the information about the mapping for APs.
151
         */
153
         */
152
        bsp_locked_dtlb_entry[bsp_locked_dtlb_entries].virt_page =
154
        bsp_locked_dtlb_entry[bsp_locked_dtlb_entries].virt_page =
153
            virtaddr + i * sizemap[order].increment;
155
            virtaddr + i * sizemap[order].increment;
154
        bsp_locked_dtlb_entry[bsp_locked_dtlb_entries].phys_page =
156
        bsp_locked_dtlb_entry[bsp_locked_dtlb_entries].phys_page =
155
            physaddr + i * sizemap[order].increment;
157
            physaddr + i * sizemap[order].increment;
156
        bsp_locked_dtlb_entry[bsp_locked_dtlb_entries].pagesize_code =
158
        bsp_locked_dtlb_entry[bsp_locked_dtlb_entries].pagesize_code =
157
            sizemap[order].pagesize_code;
159
            sizemap[order].pagesize_code;
158
        bsp_locked_dtlb_entries++;
160
        bsp_locked_dtlb_entries++;
159
#endif
161
#endif
160
    }
162
    }
161
   
163
   
162
    return virtaddr;
164
    return virtaddr;