currentMemoryDefinition.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*
  2. * arch/alpha/boot/bootpz.c
  3. *
  4. * Copyright (C) 1997 Jay Estabrook
  5. *
  6. * This file is used for creating a compressed BOOTP file for the
  7. * Linux/AXP kernel
  8. *
  9. * based significantly on the arch/alpha/boot/main.c of Linus Torvalds
  10. * and the decompression code from MILO.
  11. */
  12. #include <linux/kernel.h>
  13. #include <linux/slab.h>
  14. #include <linux/string.h>
  15. #include <generated/utsrelease.h>
  16. #include <linux/mm.h>
  17. #include <asm/console.h>
  18. #include <asm/hwrpb.h>
  19. #include <asm/pgtable.h>
  20. #include <asm/io.h>
  21. #include <stdarg.h>
  22. #include "kzsize.h"
  23. /* FIXME FIXME FIXME */
  24. #define MALLOC_AREA_SIZE 0x200000 /* 2MB for now */
  25. /* FIXME FIXME FIXME */
  26. /*
  27. WARNING NOTE
  28. It is very possible that turning on additional messages may cause
  29. kernel image corruption due to stack usage to do the printing.
  30. */
  31. #undef DEBUG_CHECK_RANGE
  32. #undef DEBUG_ADDRESSES
  33. #undef DEBUG_LAST_STEPS
  34. extern unsigned long switch_to_osf_pal(unsigned long nr,
  35. struct pcb_struct * pcb_va, struct pcb_struct * pcb_pa,
  36. unsigned long *vptb);
  37. extern int decompress_kernel(void* destination, void *source,
  38. size_t ksize, size_t kzsize);
  39. extern void move_stack(unsigned long new_stack);
  40. struct hwrpb_struct *hwrpb = INIT_HWRPB;
  41. static struct pcb_struct pcb_va[1];
  42. /*
  43. * Find a physical address of a virtual object..
  44. *
  45. * This is easy using the virtual page table address.
  46. */
  47. #define VPTB ((unsigned long *) 0x200000000)
  48. static inline unsigned long
  49. find_pa(unsigned long address)
  50. {
  51. unsigned long result;
  52. result = VPTB[address >> 13];
  53. result >>= 32;
  54. result <<= 13;
  55. result |= address & 0x1fff;
  56. return result;
  57. }
  58. int
  59. check_range(unsigned long vstart, unsigned long vend,
  60. unsigned long kstart, unsigned long kend)
  61. {
  62. unsigned long vaddr, kaddr;
  63. #ifdef DEBUG_CHECK_RANGE
  64. srm_printk("check_range: V[0x%lx:0x%lx] K[0x%lx:0x%lx]\n",
  65. vstart, vend, kstart, kend);
  66. #endif
  67. /* do some range checking for detecting an overlap... */
  68. for (vaddr = vstart; vaddr <= vend; vaddr += PAGE_SIZE)
  69. {
  70. kaddr = (find_pa(vaddr) | PAGE_OFFSET);
  71. if (kaddr >= kstart && kaddr <= kend)
  72. {
  73. #ifdef DEBUG_CHECK_RANGE
  74. srm_printk("OVERLAP: vaddr 0x%lx kaddr 0x%lx"
  75. " [0x%lx:0x%lx]\n",
  76. vaddr, kaddr, kstart, kend);
  77. #endif
  78. return 1;
  79. }
  80. }
  81. return 0;
  82. }
  83. /*
  84. * This function moves into OSF/1 pal-code, and has a temporary
  85. * PCB for that. The kernel proper should replace this PCB with
  86. * the real one as soon as possible.
  87. *
  88. * The page table muckery in here depends on the fact that the boot
  89. * code has the L1 page table identity-map itself in the second PTE
  90. * in the L1 page table. Thus the L1-page is virtually addressable
  91. * itself (through three levels) at virtual address 0x200802000.
  92. */
  93. #define L1 ((unsigned long *) 0x200802000)
  94. void
  95. pal_init(void)
  96. {
  97. unsigned long i, rev;
  98. struct percpu_struct * percpu;
  99. struct pcb_struct * pcb_pa;
  100. /* Create the dummy PCB. */
  101. pcb_va->ksp = 0;
  102. pcb_va->usp = 0;
  103. pcb_va->ptbr = L1[1] >> 32;
  104. pcb_va->asn = 0;
  105. pcb_va->pcc = 0;
  106. pcb_va->unique = 0;
  107. pcb_va->flags = 1;
  108. pcb_va->res1 = 0;
  109. pcb_va->res2 = 0;
  110. pcb_pa = (struct pcb_struct *)find_pa((unsigned long)pcb_va);
  111. /*
  112. * a0 = 2 (OSF)
  113. * a1 = return address, but we give the asm the vaddr of the PCB
  114. * a2 = physical addr of PCB
  115. * a3 = new virtual page table pointer
  116. * a4 = KSP (but the asm sets it)
  117. */
  118. srm_printk("Switching to OSF PAL-code... ");
  119. i = switch_to_osf_pal(2, pcb_va, pcb_pa, VPTB);
  120. if (i) {
  121. srm_printk("failed, code %ld\n", i);
  122. __halt();
  123. }
  124. percpu = (struct percpu_struct *)
  125. (INIT_HWRPB->processor_offset + (unsigned long) INIT_HWRPB);
  126. rev = percpu->pal_revision = percpu->palcode_avail[2];
  127. srm_printk("OK (rev %lx)\n", rev);
  128. tbia(); /* do it directly in case we are SMP */
  129. }