init_32.c (05f209e7b936a48e341d36831079116a06658ccc) init_32.c (e5b2bb552706ca0e30795ee84caacbb37cec5705)
1/*
2 *
3 * Copyright (C) 1995 Linus Torvalds
4 *
5 * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
6 */
7
8#include <linux/module.h>

--- 1198 unchanged lines hidden (view full) ---

1207 set_pages_rw(virt_to_page(start), size >> PAGE_SHIFT);
1208
1209 printk(KERN_INFO "Testing CPA: write protecting again\n");
1210 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
1211#endif
1212}
1213#endif
1214
1/*
2 *
3 * Copyright (C) 1995 Linus Torvalds
4 *
5 * Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
6 */
7
8#include <linux/module.h>

--- 1198 unchanged lines hidden (view full) ---

1207 set_pages_rw(virt_to_page(start), size >> PAGE_SHIFT);
1208
1209 printk(KERN_INFO "Testing CPA: write protecting again\n");
1210 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
1211#endif
1212}
1213#endif
1214
1215void free_init_pages(char *what, unsigned long begin, unsigned long end)
1216{
1217 unsigned long addr = begin;
1218
1219 if (addr >= end)
1220 return;
1221
1222 /*
1223 * If debugging page accesses then do not free this memory but
1224 * mark them not present - any buggy init-section access will
1225 * create a kernel page fault:
1226 */
1227#ifdef CONFIG_DEBUG_PAGEALLOC
1228 printk(KERN_INFO "debug: unmapping init memory %08lx..%08lx\n",
1229 begin, PAGE_ALIGN(end));
1230 set_memory_np(begin, (end - begin) >> PAGE_SHIFT);
1231#else
1232 /*
1233 * We just marked the kernel text read only above, now that
1234 * we are going to free part of that, we need to make that
1235 * writeable first.
1236 */
1237 set_memory_rw(begin, (end - begin) >> PAGE_SHIFT);
1238
1239 printk(KERN_INFO "Freeing %s: %luk freed\n", what, (end - begin) >> 10);
1240
1241 for (; addr < end; addr += PAGE_SIZE) {
1242 ClearPageReserved(virt_to_page(addr));
1243 init_page_count(virt_to_page(addr));
1244 memset((void *)(addr & ~(PAGE_SIZE-1)),
1245 POISON_FREE_INITMEM, PAGE_SIZE);
1246 free_page(addr);
1247 totalram_pages++;
1248 }
1249#endif
1250}
1251
1252void free_initmem(void)
1253{
1254 free_init_pages("unused kernel memory",
1255 (unsigned long)(&__init_begin),
1256 (unsigned long)(&__init_end));
1257}
1258
1259#ifdef CONFIG_BLK_DEV_INITRD
1260void free_initrd_mem(unsigned long start, unsigned long end)
1261{
1262 free_init_pages("initrd memory", start, end);
1263}
1264#endif
1265
1266int __init reserve_bootmem_generic(unsigned long phys, unsigned long len,
1267 int flags)
1268{
1269 return reserve_bootmem(phys, len, flags);
1270}
1215#ifdef CONFIG_BLK_DEV_INITRD
1216void free_initrd_mem(unsigned long start, unsigned long end)
1217{
1218 free_init_pages("initrd memory", start, end);
1219}
1220#endif
1221
1222int __init reserve_bootmem_generic(unsigned long phys, unsigned long len,
1223 int flags)
1224{
1225 return reserve_bootmem(phys, len, flags);
1226}