lmb.h 2.3 KB

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