lmb.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #ifndef _ASM_POWERPC_LMB_H
  2. #define _ASM_POWERPC_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. struct lmb_property {
  19. unsigned long base;
  20. unsigned long size;
  21. };
  22. struct lmb_region {
  23. unsigned long cnt;
  24. unsigned long size;
  25. struct lmb_property region[MAX_LMB_REGIONS+1];
  26. };
  27. struct lmb {
  28. unsigned long debug;
  29. unsigned long rmo_size;
  30. struct lmb_region memory;
  31. struct lmb_region reserved;
  32. };
  33. extern struct lmb lmb;
  34. extern void __init lmb_init(void);
  35. extern void __init lmb_analyze(void);
  36. extern long __init lmb_add(unsigned long base, unsigned long size);
  37. extern long __init lmb_reserve(unsigned long base, unsigned long size);
  38. extern unsigned long __init lmb_alloc(unsigned long size, unsigned long align);
  39. extern unsigned long __init lmb_alloc_base(unsigned long size,
  40. unsigned long align, unsigned long max_addr);
  41. extern unsigned long __init __lmb_alloc_base(unsigned long size,
  42. unsigned long align, unsigned long max_addr);
  43. extern unsigned long __init lmb_phys_mem_size(void);
  44. extern unsigned long __init lmb_end_of_DRAM(void);
  45. extern void __init lmb_enforce_memory_limit(unsigned long memory_limit);
  46. extern int __init lmb_is_reserved(unsigned long addr);
  47. extern void lmb_dump_all(void);
  48. static inline unsigned long
  49. lmb_size_bytes(struct lmb_region *type, unsigned long region_nr)
  50. {
  51. return type->region[region_nr].size;
  52. }
  53. static inline unsigned long
  54. lmb_size_pages(struct lmb_region *type, unsigned long region_nr)
  55. {
  56. return lmb_size_bytes(type, region_nr) >> PAGE_SHIFT;
  57. }
  58. static inline unsigned long
  59. lmb_start_pfn(struct lmb_region *type, unsigned long region_nr)
  60. {
  61. return type->region[region_nr].base >> PAGE_SHIFT;
  62. }
  63. static inline unsigned long
  64. lmb_end_pfn(struct lmb_region *type, unsigned long region_nr)
  65. {
  66. return lmb_start_pfn(type, region_nr) +
  67. lmb_size_pages(type, region_nr);
  68. }
  69. #endif /* __KERNEL__ */
  70. #endif /* _ASM_POWERPC_LMB_H */