Locking pages in memory

From: A V Naga Muni Reddy (nmreddy@sasi.com)
Date: Wed Mar 22 2000 - 06:32:11 EST


Hi,

        I need to lock some pages in memory.
And those pages should be made non-caceable.

        I tried to do it by the procedure
specified in the attached program. This
is failing. Is there any other way??
------------------------------------------
#define __KERNEL__
#define MODULE
#include <linux/config.h>
#include <linux/pci.h>
#include <linux/delay.h>
#include <linux/module.h>
#include <linux/vmalloc.h>
#include <linux/mm.h>
#include <linux/ioctl.h>
#include <asm/uaccess.h>
#include <asm/io.h>

static char *table;
static char *table_end;
static u32 size;
static unsigned long *cmd_table_remapped;
static u32 page_order;

#define CACHE_FLUSH() asm volatile ("wbinvd":::"memory")

int init_module(void)
{

            u32 i;
            page_order = 4;
            table = (char *) __get_free_pages(GFP_KERNEL, page_order);

        if (table == NULL) {
                return -ENOMEM;
        }
        table_end = table + ((PAGE_SIZE * (1 << page_order)) - 1);

        for (i = MAP_NR(table); i < MAP_NR(table_end); i++) {
                set_bit(PG_reserved, &mem_map[i].flags);
        }

        CACHE_FLUSH();
        cmd_table_remapped = ioremap_nocache(virt_to_phys(table),
                                        (PAGE_SIZE * (1 << page_order)));
        if (cmd_table_remapped == NULL) {
        printk("<1> ioremapping not succeded \n");
                for (i = MAP_NR(table); i < MAP_NR(table_end); i++) {
                        clear_bit(PG_reserved, &mem_map[i].flags);
                }
                free_pages((unsigned long) table, page_order);
                return 1;
        }
            printk("<1> ioremapping succeded \n");
            return 0;
}

void cleanup_module(void)
{
        /* TODO cleanup */
        printk("<1> cleanup module called \n");
}
------------------------------------------
        Can any one suggest me how to do it.

Thanks & Regards,
---------------------------------------
Muni Reddy
Ph. 5281461 ext 4137
---------------------------------------

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Mar 23 2000 - 21:00:35 EST