source: trunk/hal/x86_64/core/hal_ppm.c @ 111

Last change on this file since 111 was 110, checked in by max@…, 7 years ago

add some code for ppm_init

File size: 1.8 KB
Line 
1/*
2 * hal_ppm.c - Generic Physical Page Manager API implementation for x86
3 *
4 * Copyright (c) 2017 Maxime Villard
5 *
6 * This file is part of ALMOS-MKH.
7 *
8 * ALMOS-MKH is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2.0 of the License.
11 *
12 * ALMOS-MKH is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with ALMOS-MKH.; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22#include <kernel_config.h>
23#include <hal_types.h>
24#include <hal_ppm.h>
25#include <hal_special.h>
26#include <printk.h>
27#include <spinlock.h>
28#include <process.h>
29#include <ppm.h>
30#include <thread.h>
31#include <cluster.h>
32#include <page.h>
33
34#include <hal_internal.h>
35
36error_t hal_ppm_init(boot_info_t *info)
37{
38        size_t i;
39
40        // get relevant info from boot_info structure
41        uint32_t pages_nr         = info->pages_nr;
42        uint32_t pages_tbl_offset = info->pages_offset;
43        uint32_t rsvd_nr          = info->rsvd_nr;
44
45        // get pointer on local Physical Page Manager
46        ppm_t * ppm = &LOCAL_CLUSTER->ppm;
47
48        // initialize lock protecting the free_pages[] lists
49        spinlock_init( &ppm->free_lock );
50
51        // initialize lock protecting the dirty_pages list
52        spinlock_init( &ppm->dirty_lock );
53
54        // initialize all free_pages[] lists as empty
55        for( i = 0 ; i < CONFIG_PPM_MAX_ORDER ; i++ )
56        {
57                list_root_init( &ppm->free_pages_root[i] );
58                ppm->free_pages_nr[i] = 0;
59        }
60
61        // TODO
62
63        x86_panic((char *)__func__);
64        return 0;
65}
66
Note: See TracBrowser for help on using the repository browser.