lmb.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. #ifndef _LINUX_LMB_H
  2. #define _LINUX_LMB_H
  3. #ifdef __KERNEL__
  4. /*
  5. * Logical memory blocks.
  6. *
  7. * Copyright (C) 2001 Peter Bergner, IBM Corp.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License
  11. * as published by the Free Software Foundation; either version
  12. * 2 of the License, or (at your option) any later version.
  13. */
  14. #include <linux/init.h>
  15. #include <linux/mm.h>
  16. #define MAX_LMB_REGIONS 128
  17. struct lmb_property {
  18. unsigned long base;
  19. unsigned long size;
  20. };
  21. struct lmb_region {
  22. unsigned long cnt;
  23. unsigned long size;
  24. struct lmb_property region[MAX_LMB_REGIONS+1];
  25. };
  26. struct lmb {
  27. unsigned long debug;
  28. unsigned long rmo_size;
  29. struct lmb_region memory;
  30. struct lmb_region reserved;
  31. };
  32. extern struct lmb lmb;
  33. extern void __init lmb_init(void);
  34. extern void __init lmb_analyze(void);
  35. extern long __init lmb_add(unsigned long base, unsigned long size);
  36. extern long __init lmb_reserve(unsigned long base, unsigned long size);
  37. extern unsigned long __init lmb_alloc(unsigned long size, unsigned long align);
  38. extern unsigned long __init lmb_alloc_base(unsigned long size,
  39. unsigned long align, unsigned long max_addr);
  40. extern unsigned long __init __lmb_alloc_base(unsigned long size,
  41. unsigned long align, unsigned long max_addr);
  42. extern unsigned long __init lmb_phys_mem_size(void);
  43. extern unsigned long __init lmb_end_of_DRAM(void);
  44. extern void __init lmb_enforce_memory_limit(unsigned long memory_limit);
  45. extern int __init lmb_is_reserved(unsigned long addr);
  46. extern void lmb_dump_all(void);
  47. static inline unsigned long
  48. lmb_size_bytes(struct lmb_region *type, unsigned long region_nr)
  49. {
  50. return type->region[region_nr].size;
  51. }
  52. static inline unsigned long
  53. lmb_size_pages(struct lmb_region *type, unsigned long region_nr)
  54. {
  55. return lmb_size_bytes(type, region_nr) >> PAGE_SHIFT;
  56. }
  57. static inline unsigned long
  58. lmb_start_pfn(struct lmb_region *type, unsigned long region_nr)
  59. {
  60. return type->region[region_nr].base >> PAGE_SHIFT;
  61. }
  62. static inline unsigned long
  63. lmb_end_pfn(struct lmb_region *type, unsigned long region_nr)
  64. {
  65. return lmb_start_pfn(type, region_nr) +
  66. lmb_size_pages(type, region_nr);
  67. }
  68. #include <asm/lmb.h>
  69. #endif /* __KERNEL__ */
  70. #endif /* _LINUX_LMB_H */