ioremap.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. /*
  2. * Re-map IO memory to kernel address space so that we can access it.
  3. * This is needed for high PCI addresses that aren't mapped in the
  4. * 640k-1MB IO memory area on PC's
  5. *
  6. * (C) Copyright 1995 1996 Linus Torvalds
  7. */
  8. #include <linux/bootmem.h>
  9. #include <linux/init.h>
  10. #include <linux/io.h>
  11. #include <linux/module.h>
  12. #include <linux/slab.h>
  13. #include <linux/vmalloc.h>
  14. #include <linux/mmiotrace.h>
  15. #include <asm/cacheflush.h>
  16. #include <asm/e820.h>
  17. #include <asm/fixmap.h>
  18. #include <asm/pgtable.h>
  19. #include <asm/tlbflush.h>
  20. #include <asm/pgalloc.h>
  21. #include <asm/pat.h>
  22. #ifdef CONFIG_X86_64
  23. unsigned long __phys_addr(unsigned long x)
  24. {
  25. if (x >= __START_KERNEL_map)
  26. return x - __START_KERNEL_map + phys_base;
  27. return x - PAGE_OFFSET;
  28. }
  29. EXPORT_SYMBOL(__phys_addr);
  30. static inline int phys_addr_valid(unsigned long addr)
  31. {
  32. return addr < (1UL << boot_cpu_data.x86_phys_bits);
  33. }
  34. #else
  35. static inline int phys_addr_valid(unsigned long addr)
  36. {
  37. return 1;
  38. }
  39. #endif
  40. int page_is_ram(unsigned long pagenr)
  41. {
  42. resource_size_t addr, end;
  43. int i;
  44. /*
  45. * A special case is the first 4Kb of memory;
  46. * This is a BIOS owned area, not kernel ram, but generally
  47. * not listed as such in the E820 table.
  48. */
  49. if (pagenr == 0)
  50. return 0;
  51. /*
  52. * Second special case: Some BIOSen report the PC BIOS
  53. * area (640->1Mb) as ram even though it is not.
  54. */
  55. if (pagenr >= (BIOS_BEGIN >> PAGE_SHIFT) &&
  56. pagenr < (BIOS_END >> PAGE_SHIFT))
  57. return 0;
  58. for (i = 0; i < e820.nr_map; i++) {
  59. /*
  60. * Not usable memory:
  61. */
  62. if (e820.map[i].type != E820_RAM)
  63. continue;
  64. addr = (e820.map[i].addr + PAGE_SIZE-1) >> PAGE_SHIFT;
  65. end = (e820.map[i].addr + e820.map[i].size) >> PAGE_SHIFT;
  66. if ((pagenr >= addr) && (pagenr < end))
  67. return 1;
  68. }
  69. return 0;
  70. }
  71. int pagerange_is_ram(unsigned long start, unsigned long end)
  72. {
  73. int ram_page = 0, not_rampage = 0;
  74. unsigned long page_nr;
  75. for (page_nr = (start >> PAGE_SHIFT); page_nr < (end >> PAGE_SHIFT);
  76. ++page_nr) {
  77. if (page_is_ram(page_nr))
  78. ram_page = 1;
  79. else
  80. not_rampage = 1;
  81. if (ram_page == not_rampage)
  82. return -1;
  83. }
  84. return ram_page;
  85. }
  86. /*
  87. * Fix up the linear direct mapping of the kernel to avoid cache attribute
  88. * conflicts.
  89. */
  90. int ioremap_change_attr(unsigned long vaddr, unsigned long size,
  91. unsigned long prot_val)
  92. {
  93. unsigned long nrpages = size >> PAGE_SHIFT;
  94. int err;
  95. switch (prot_val) {
  96. case _PAGE_CACHE_UC:
  97. default:
  98. err = _set_memory_uc(vaddr, nrpages);
  99. break;
  100. case _PAGE_CACHE_WC:
  101. err = _set_memory_wc(vaddr, nrpages);
  102. break;
  103. case _PAGE_CACHE_WB:
  104. err = _set_memory_wb(vaddr, nrpages);
  105. break;
  106. }
  107. return err;
  108. }
  109. /*
  110. * Remap an arbitrary physical address space into the kernel virtual
  111. * address space. Needed when the kernel wants to access high addresses
  112. * directly.
  113. *
  114. * NOTE! We need to allow non-page-aligned mappings too: we will obviously
  115. * have to convert them into an offset in a page-aligned mapping, but the
  116. * caller shouldn't need to know that small detail.
  117. */
  118. static void __iomem *__ioremap_caller(resource_size_t phys_addr,
  119. unsigned long size, unsigned long prot_val, void *caller)
  120. {
  121. unsigned long pfn, offset, vaddr;
  122. resource_size_t last_addr;
  123. const resource_size_t unaligned_phys_addr = phys_addr;
  124. const unsigned long unaligned_size = size;
  125. struct vm_struct *area;
  126. unsigned long new_prot_val;
  127. pgprot_t prot;
  128. int retval;
  129. void __iomem *ret_addr;
  130. /* Don't allow wraparound or zero size */
  131. last_addr = phys_addr + size - 1;
  132. if (!size || last_addr < phys_addr)
  133. return NULL;
  134. if (!phys_addr_valid(phys_addr)) {
  135. printk(KERN_WARNING "ioremap: invalid physical address %llx\n",
  136. (unsigned long long)phys_addr);
  137. WARN_ON_ONCE(1);
  138. return NULL;
  139. }
  140. /*
  141. * Don't remap the low PCI/ISA area, it's always mapped..
  142. */
  143. if (is_ISA_range(phys_addr, last_addr))
  144. return (__force void __iomem *)phys_to_virt(phys_addr);
  145. /*
  146. * Don't allow anybody to remap normal RAM that we're using..
  147. */
  148. for (pfn = phys_addr >> PAGE_SHIFT;
  149. (pfn << PAGE_SHIFT) < (last_addr & PAGE_MASK);
  150. pfn++) {
  151. int is_ram = page_is_ram(pfn);
  152. if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
  153. return NULL;
  154. WARN_ON_ONCE(is_ram);
  155. }
  156. /*
  157. * Mappings have to be page-aligned
  158. */
  159. offset = phys_addr & ~PAGE_MASK;
  160. phys_addr &= PAGE_MASK;
  161. size = PAGE_ALIGN(last_addr+1) - phys_addr;
  162. retval = reserve_memtype(phys_addr, (u64)phys_addr + size,
  163. prot_val, &new_prot_val);
  164. if (retval) {
  165. pr_debug("Warning: reserve_memtype returned %d\n", retval);
  166. return NULL;
  167. }
  168. if (prot_val != new_prot_val) {
  169. /*
  170. * Do not fallback to certain memory types with certain
  171. * requested type:
  172. * - request is uc-, return cannot be write-back
  173. * - request is uc-, return cannot be write-combine
  174. * - request is write-combine, return cannot be write-back
  175. */
  176. if ((prot_val == _PAGE_CACHE_UC_MINUS &&
  177. (new_prot_val == _PAGE_CACHE_WB ||
  178. new_prot_val == _PAGE_CACHE_WC)) ||
  179. (prot_val == _PAGE_CACHE_WC &&
  180. new_prot_val == _PAGE_CACHE_WB)) {
  181. pr_debug(
  182. "ioremap error for 0x%llx-0x%llx, requested 0x%lx, got 0x%lx\n",
  183. (unsigned long long)phys_addr,
  184. (unsigned long long)(phys_addr + size),
  185. prot_val, new_prot_val);
  186. free_memtype(phys_addr, phys_addr + size);
  187. return NULL;
  188. }
  189. prot_val = new_prot_val;
  190. }
  191. switch (prot_val) {
  192. case _PAGE_CACHE_UC:
  193. default:
  194. prot = PAGE_KERNEL_NOCACHE;
  195. break;
  196. case _PAGE_CACHE_UC_MINUS:
  197. prot = PAGE_KERNEL_UC_MINUS;
  198. break;
  199. case _PAGE_CACHE_WC:
  200. prot = PAGE_KERNEL_WC;
  201. break;
  202. case _PAGE_CACHE_WB:
  203. prot = PAGE_KERNEL;
  204. break;
  205. }
  206. /*
  207. * Ok, go for it..
  208. */
  209. area = get_vm_area_caller(size, VM_IOREMAP, caller);
  210. if (!area)
  211. return NULL;
  212. area->phys_addr = phys_addr;
  213. vaddr = (unsigned long) area->addr;
  214. if (ioremap_page_range(vaddr, vaddr + size, phys_addr, prot)) {
  215. free_memtype(phys_addr, phys_addr + size);
  216. free_vm_area(area);
  217. return NULL;
  218. }
  219. if (ioremap_change_attr(vaddr, size, prot_val) < 0) {
  220. free_memtype(phys_addr, phys_addr + size);
  221. vunmap(area->addr);
  222. return NULL;
  223. }
  224. ret_addr = (void __iomem *) (vaddr + offset);
  225. mmiotrace_ioremap(unaligned_phys_addr, unaligned_size, ret_addr);
  226. return ret_addr;
  227. }
  228. /**
  229. * ioremap_nocache - map bus memory into CPU space
  230. * @offset: bus address of the memory
  231. * @size: size of the resource to map
  232. *
  233. * ioremap_nocache performs a platform specific sequence of operations to
  234. * make bus memory CPU accessible via the readb/readw/readl/writeb/
  235. * writew/writel functions and the other mmio helpers. The returned
  236. * address is not guaranteed to be usable directly as a virtual
  237. * address.
  238. *
  239. * This version of ioremap ensures that the memory is marked uncachable
  240. * on the CPU as well as honouring existing caching rules from things like
  241. * the PCI bus. Note that there are other caches and buffers on many
  242. * busses. In particular driver authors should read up on PCI writes
  243. *
  244. * It's useful if some control registers are in such an area and
  245. * write combining or read caching is not desirable:
  246. *
  247. * Must be freed with iounmap.
  248. */
  249. void __iomem *ioremap_nocache(resource_size_t phys_addr, unsigned long size)
  250. {
  251. /*
  252. * Ideally, this should be:
  253. * pat_enabled ? _PAGE_CACHE_UC : _PAGE_CACHE_UC_MINUS;
  254. *
  255. * Till we fix all X drivers to use ioremap_wc(), we will use
  256. * UC MINUS.
  257. */
  258. unsigned long val = _PAGE_CACHE_UC_MINUS;
  259. return __ioremap_caller(phys_addr, size, val,
  260. __builtin_return_address(0));
  261. }
  262. EXPORT_SYMBOL(ioremap_nocache);
  263. /**
  264. * ioremap_wc - map memory into CPU space write combined
  265. * @offset: bus address of the memory
  266. * @size: size of the resource to map
  267. *
  268. * This version of ioremap ensures that the memory is marked write combining.
  269. * Write combining allows faster writes to some hardware devices.
  270. *
  271. * Must be freed with iounmap.
  272. */
  273. void __iomem *ioremap_wc(unsigned long phys_addr, unsigned long size)
  274. {
  275. if (pat_enabled)
  276. return __ioremap_caller(phys_addr, size, _PAGE_CACHE_WC,
  277. __builtin_return_address(0));
  278. else
  279. return ioremap_nocache(phys_addr, size);
  280. }
  281. EXPORT_SYMBOL(ioremap_wc);
  282. void __iomem *ioremap_cache(resource_size_t phys_addr, unsigned long size)
  283. {
  284. return __ioremap_caller(phys_addr, size, _PAGE_CACHE_WB,
  285. __builtin_return_address(0));
  286. }
  287. EXPORT_SYMBOL(ioremap_cache);
  288. static void __iomem *ioremap_default(resource_size_t phys_addr,
  289. unsigned long size)
  290. {
  291. unsigned long flags;
  292. void *ret;
  293. int err;
  294. /*
  295. * - WB for WB-able memory and no other conflicting mappings
  296. * - UC_MINUS for non-WB-able memory with no other conflicting mappings
  297. * - Inherit from confliting mappings otherwise
  298. */
  299. err = reserve_memtype(phys_addr, phys_addr + size, -1, &flags);
  300. if (err < 0)
  301. return NULL;
  302. ret = (void *) __ioremap_caller(phys_addr, size, flags,
  303. __builtin_return_address(0));
  304. free_memtype(phys_addr, phys_addr + size);
  305. return (void __iomem *)ret;
  306. }
  307. void __iomem *ioremap_prot(resource_size_t phys_addr, unsigned long size,
  308. unsigned long prot_val)
  309. {
  310. return __ioremap_caller(phys_addr, size, (prot_val & _PAGE_CACHE_MASK),
  311. __builtin_return_address(0));
  312. }
  313. EXPORT_SYMBOL(ioremap_prot);
  314. /**
  315. * iounmap - Free a IO remapping
  316. * @addr: virtual address from ioremap_*
  317. *
  318. * Caller must ensure there is only one unmapping for the same pointer.
  319. */
  320. void iounmap(volatile void __iomem *addr)
  321. {
  322. struct vm_struct *p, *o;
  323. if ((void __force *)addr <= high_memory)
  324. return;
  325. /*
  326. * __ioremap special-cases the PCI/ISA range by not instantiating a
  327. * vm_area and by simply returning an address into the kernel mapping
  328. * of ISA space. So handle that here.
  329. */
  330. if ((void __force *)addr >= phys_to_virt(ISA_START_ADDRESS) &&
  331. (void __force *)addr < phys_to_virt(ISA_END_ADDRESS))
  332. return;
  333. addr = (volatile void __iomem *)
  334. (PAGE_MASK & (unsigned long __force)addr);
  335. mmiotrace_iounmap(addr);
  336. /* Use the vm area unlocked, assuming the caller
  337. ensures there isn't another iounmap for the same address
  338. in parallel. Reuse of the virtual address is prevented by
  339. leaving it in the global lists until we're done with it.
  340. cpa takes care of the direct mappings. */
  341. read_lock(&vmlist_lock);
  342. for (p = vmlist; p; p = p->next) {
  343. if (p->addr == (void __force *)addr)
  344. break;
  345. }
  346. read_unlock(&vmlist_lock);
  347. if (!p) {
  348. printk(KERN_ERR "iounmap: bad address %p\n", addr);
  349. dump_stack();
  350. return;
  351. }
  352. free_memtype(p->phys_addr, p->phys_addr + get_vm_area_size(p));
  353. /* Finally remove it */
  354. o = remove_vm_area((void __force *)addr);
  355. BUG_ON(p != o || o == NULL);
  356. kfree(p);
  357. }
  358. EXPORT_SYMBOL(iounmap);
  359. /*
  360. * Convert a physical pointer to a virtual kernel pointer for /dev/mem
  361. * access
  362. */
  363. void *xlate_dev_mem_ptr(unsigned long phys)
  364. {
  365. void *addr;
  366. unsigned long start = phys & PAGE_MASK;
  367. /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
  368. if (page_is_ram(start >> PAGE_SHIFT))
  369. return __va(phys);
  370. addr = (void __force *)ioremap_default(start, PAGE_SIZE);
  371. if (addr)
  372. addr = (void *)((unsigned long)addr | (phys & ~PAGE_MASK));
  373. return addr;
  374. }
  375. void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
  376. {
  377. if (page_is_ram(phys >> PAGE_SHIFT))
  378. return;
  379. iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
  380. return;
  381. }
  382. static int __initdata early_ioremap_debug;
  383. static int __init early_ioremap_debug_setup(char *str)
  384. {
  385. early_ioremap_debug = 1;
  386. return 0;
  387. }
  388. early_param("early_ioremap_debug", early_ioremap_debug_setup);
  389. static __initdata int after_paging_init;
  390. static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
  391. static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
  392. {
  393. /* Don't assume we're using swapper_pg_dir at this point */
  394. pgd_t *base = __va(read_cr3());
  395. pgd_t *pgd = &base[pgd_index(addr)];
  396. pud_t *pud = pud_offset(pgd, addr);
  397. pmd_t *pmd = pmd_offset(pud, addr);
  398. return pmd;
  399. }
  400. static inline pte_t * __init early_ioremap_pte(unsigned long addr)
  401. {
  402. return &bm_pte[pte_index(addr)];
  403. }
  404. void __init early_ioremap_init(void)
  405. {
  406. pmd_t *pmd;
  407. if (early_ioremap_debug)
  408. printk(KERN_INFO "early_ioremap_init()\n");
  409. pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
  410. memset(bm_pte, 0, sizeof(bm_pte));
  411. pmd_populate_kernel(&init_mm, pmd, bm_pte);
  412. /*
  413. * The boot-ioremap range spans multiple pmds, for which
  414. * we are not prepared:
  415. */
  416. if (pmd != early_ioremap_pmd(fix_to_virt(FIX_BTMAP_END))) {
  417. WARN_ON(1);
  418. printk(KERN_WARNING "pmd %p != %p\n",
  419. pmd, early_ioremap_pmd(fix_to_virt(FIX_BTMAP_END)));
  420. printk(KERN_WARNING "fix_to_virt(FIX_BTMAP_BEGIN): %08lx\n",
  421. fix_to_virt(FIX_BTMAP_BEGIN));
  422. printk(KERN_WARNING "fix_to_virt(FIX_BTMAP_END): %08lx\n",
  423. fix_to_virt(FIX_BTMAP_END));
  424. printk(KERN_WARNING "FIX_BTMAP_END: %d\n", FIX_BTMAP_END);
  425. printk(KERN_WARNING "FIX_BTMAP_BEGIN: %d\n",
  426. FIX_BTMAP_BEGIN);
  427. }
  428. }
  429. void __init early_ioremap_clear(void)
  430. {
  431. pmd_t *pmd;
  432. if (early_ioremap_debug)
  433. printk(KERN_INFO "early_ioremap_clear()\n");
  434. pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
  435. pmd_clear(pmd);
  436. paravirt_release_pte(__pa(bm_pte) >> PAGE_SHIFT);
  437. __flush_tlb_all();
  438. }
  439. void __init early_ioremap_reset(void)
  440. {
  441. enum fixed_addresses idx;
  442. unsigned long addr, phys;
  443. pte_t *pte;
  444. after_paging_init = 1;
  445. for (idx = FIX_BTMAP_BEGIN; idx >= FIX_BTMAP_END; idx--) {
  446. addr = fix_to_virt(idx);
  447. pte = early_ioremap_pte(addr);
  448. if (pte_present(*pte)) {
  449. phys = pte_val(*pte) & PAGE_MASK;
  450. set_fixmap(idx, phys);
  451. }
  452. }
  453. }
  454. static void __init __early_set_fixmap(enum fixed_addresses idx,
  455. unsigned long phys, pgprot_t flags)
  456. {
  457. unsigned long addr = __fix_to_virt(idx);
  458. pte_t *pte;
  459. if (idx >= __end_of_fixed_addresses) {
  460. BUG();
  461. return;
  462. }
  463. pte = early_ioremap_pte(addr);
  464. if (pgprot_val(flags))
  465. set_pte(pte, pfn_pte(phys >> PAGE_SHIFT, flags));
  466. else
  467. pte_clear(&init_mm, addr, pte);
  468. __flush_tlb_one(addr);
  469. }
  470. static inline void __init early_set_fixmap(enum fixed_addresses idx,
  471. unsigned long phys)
  472. {
  473. if (after_paging_init)
  474. set_fixmap(idx, phys);
  475. else
  476. __early_set_fixmap(idx, phys, PAGE_KERNEL);
  477. }
  478. static inline void __init early_clear_fixmap(enum fixed_addresses idx)
  479. {
  480. if (after_paging_init)
  481. clear_fixmap(idx);
  482. else
  483. __early_set_fixmap(idx, 0, __pgprot(0));
  484. }
  485. static int __initdata early_ioremap_nested;
  486. static int __init check_early_ioremap_leak(void)
  487. {
  488. if (!early_ioremap_nested)
  489. return 0;
  490. WARN(1, KERN_WARNING
  491. "Debug warning: early ioremap leak of %d areas detected.\n",
  492. early_ioremap_nested);
  493. printk(KERN_WARNING
  494. "please boot with early_ioremap_debug and report the dmesg.\n");
  495. return 1;
  496. }
  497. late_initcall(check_early_ioremap_leak);
  498. void __init *early_ioremap(unsigned long phys_addr, unsigned long size)
  499. {
  500. unsigned long offset, last_addr;
  501. unsigned int nrpages, nesting;
  502. enum fixed_addresses idx0, idx;
  503. WARN_ON(system_state != SYSTEM_BOOTING);
  504. nesting = early_ioremap_nested;
  505. if (early_ioremap_debug) {
  506. printk(KERN_INFO "early_ioremap(%08lx, %08lx) [%d] => ",
  507. phys_addr, size, nesting);
  508. dump_stack();
  509. }
  510. /* Don't allow wraparound or zero size */
  511. last_addr = phys_addr + size - 1;
  512. if (!size || last_addr < phys_addr) {
  513. WARN_ON(1);
  514. return NULL;
  515. }
  516. if (nesting >= FIX_BTMAPS_NESTING) {
  517. WARN_ON(1);
  518. return NULL;
  519. }
  520. early_ioremap_nested++;
  521. /*
  522. * Mappings have to be page-aligned
  523. */
  524. offset = phys_addr & ~PAGE_MASK;
  525. phys_addr &= PAGE_MASK;
  526. size = PAGE_ALIGN(last_addr) - phys_addr;
  527. /*
  528. * Mappings have to fit in the FIX_BTMAP area.
  529. */
  530. nrpages = size >> PAGE_SHIFT;
  531. if (nrpages > NR_FIX_BTMAPS) {
  532. WARN_ON(1);
  533. return NULL;
  534. }
  535. /*
  536. * Ok, go for it..
  537. */
  538. idx0 = FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*nesting;
  539. idx = idx0;
  540. while (nrpages > 0) {
  541. early_set_fixmap(idx, phys_addr);
  542. phys_addr += PAGE_SIZE;
  543. --idx;
  544. --nrpages;
  545. }
  546. if (early_ioremap_debug)
  547. printk(KERN_CONT "%08lx + %08lx\n", offset, fix_to_virt(idx0));
  548. return (void *) (offset + fix_to_virt(idx0));
  549. }
  550. void __init early_iounmap(void *addr, unsigned long size)
  551. {
  552. unsigned long virt_addr;
  553. unsigned long offset;
  554. unsigned int nrpages;
  555. enum fixed_addresses idx;
  556. int nesting;
  557. nesting = --early_ioremap_nested;
  558. if (WARN_ON(nesting < 0))
  559. return;
  560. if (early_ioremap_debug) {
  561. printk(KERN_INFO "early_iounmap(%p, %08lx) [%d]\n", addr,
  562. size, nesting);
  563. dump_stack();
  564. }
  565. virt_addr = (unsigned long)addr;
  566. if (virt_addr < fix_to_virt(FIX_BTMAP_BEGIN)) {
  567. WARN_ON(1);
  568. return;
  569. }
  570. offset = virt_addr & ~PAGE_MASK;
  571. nrpages = PAGE_ALIGN(offset + size - 1) >> PAGE_SHIFT;
  572. idx = FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*nesting;
  573. while (nrpages > 0) {
  574. early_clear_fixmap(idx);
  575. --idx;
  576. --nrpages;
  577. }
  578. }
  579. void __this_fixmap_does_not_exist(void)
  580. {
  581. WARN_ON(1);
  582. }