Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2000 Mike Corrigan <mikejc@us.ibm.com> |
| 3 | * Copyright (c) 1999-2000 Grant Erickson <grant@lcse.umn.edu> |
| 4 | * |
| 5 | * Module name: iSeries_setup.c |
| 6 | * |
| 7 | * Description: |
| 8 | * Architecture- / platform-specific boot-time initialization code for |
| 9 | * the IBM iSeries LPAR. Adapted from original code by Grant Erickson and |
| 10 | * code by Gary Thomas, Cort Dougan <cort@fsmlabs.com>, and Dan Malek |
| 11 | * <dan@net4x.com>. |
| 12 | * |
| 13 | * This program is free software; you can redistribute it and/or |
| 14 | * modify it under the terms of the GNU General Public License |
| 15 | * as published by the Free Software Foundation; either version |
| 16 | * 2 of the License, or (at your option) any later version. |
| 17 | */ |
| 18 | |
| 19 | #undef DEBUG |
| 20 | |
| 21 | #include <linux/config.h> |
| 22 | #include <linux/init.h> |
| 23 | #include <linux/threads.h> |
| 24 | #include <linux/smp.h> |
| 25 | #include <linux/param.h> |
| 26 | #include <linux/string.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | #include <linux/initrd.h> |
| 28 | #include <linux/seq_file.h> |
| 29 | #include <linux/kdev_t.h> |
| 30 | #include <linux/major.h> |
| 31 | #include <linux/root_dev.h> |
| 32 | |
| 33 | #include <asm/processor.h> |
| 34 | #include <asm/machdep.h> |
| 35 | #include <asm/page.h> |
| 36 | #include <asm/mmu.h> |
| 37 | #include <asm/pgtable.h> |
| 38 | #include <asm/mmu_context.h> |
| 39 | #include <asm/cputable.h> |
| 40 | #include <asm/sections.h> |
| 41 | #include <asm/iommu.h> |
Stephen Rothwell | aed3135 | 2005-08-03 14:43:21 +1000 | [diff] [blame] | 42 | #include <asm/firmware.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | |
| 44 | #include <asm/time.h> |
| 45 | #include "iSeries_setup.h" |
| 46 | #include <asm/naca.h> |
| 47 | #include <asm/paca.h> |
| 48 | #include <asm/cache.h> |
| 49 | #include <asm/sections.h> |
Stephen Rothwell | 0bc0ffd | 2005-06-21 17:15:36 -0700 | [diff] [blame] | 50 | #include <asm/abs_addr.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | #include <asm/iSeries/HvCallHpt.h> |
| 52 | #include <asm/iSeries/HvLpConfig.h> |
| 53 | #include <asm/iSeries/HvCallEvent.h> |
| 54 | #include <asm/iSeries/HvCallSm.h> |
| 55 | #include <asm/iSeries/HvCallXm.h> |
| 56 | #include <asm/iSeries/ItLpQueue.h> |
| 57 | #include <asm/iSeries/IoHriMainStore.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | #include <asm/iSeries/mf.h> |
| 59 | #include <asm/iSeries/HvLpEvent.h> |
| 60 | #include <asm/iSeries/iSeries_irq.h> |
Stephen Rothwell | 0bc0ffd | 2005-06-21 17:15:36 -0700 | [diff] [blame] | 61 | #include <asm/iSeries/IoHriProcessorVpd.h> |
| 62 | #include <asm/iSeries/ItVpdAreas.h> |
| 63 | #include <asm/iSeries/LparMap.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | |
| 65 | extern void hvlog(char *fmt, ...); |
| 66 | |
| 67 | #ifdef DEBUG |
| 68 | #define DBG(fmt...) hvlog(fmt) |
| 69 | #else |
| 70 | #define DBG(fmt...) |
| 71 | #endif |
| 72 | |
| 73 | /* Function Prototypes */ |
| 74 | extern void ppcdbg_initialize(void); |
| 75 | |
| 76 | static void build_iSeries_Memory_Map(void); |
| 77 | static void setup_iSeries_cache_sizes(void); |
| 78 | static void iSeries_bolt_kernel(unsigned long saddr, unsigned long eaddr); |
Stephen Rothwell | 145d01e | 2005-06-21 17:15:52 -0700 | [diff] [blame] | 79 | #ifdef CONFIG_PCI |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | extern void iSeries_pci_final_fixup(void); |
Stephen Rothwell | 145d01e | 2005-06-21 17:15:52 -0700 | [diff] [blame] | 81 | #else |
| 82 | static void iSeries_pci_final_fixup(void) { } |
| 83 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | |
| 85 | /* Global Variables */ |
| 86 | static unsigned long procFreqHz; |
| 87 | static unsigned long procFreqMhz; |
| 88 | static unsigned long procFreqMhzHundreths; |
| 89 | |
| 90 | static unsigned long tbFreqHz; |
| 91 | static unsigned long tbFreqMhz; |
| 92 | static unsigned long tbFreqMhzHundreths; |
| 93 | |
| 94 | int piranha_simulator; |
| 95 | |
| 96 | extern int rd_size; /* Defined in drivers/block/rd.c */ |
| 97 | extern unsigned long klimit; |
| 98 | extern unsigned long embedded_sysmap_start; |
| 99 | extern unsigned long embedded_sysmap_end; |
| 100 | |
| 101 | extern unsigned long iSeries_recal_tb; |
| 102 | extern unsigned long iSeries_recal_titan; |
| 103 | |
| 104 | static int mf_initialized; |
| 105 | |
| 106 | struct MemoryBlock { |
| 107 | unsigned long absStart; |
| 108 | unsigned long absEnd; |
| 109 | unsigned long logicalStart; |
| 110 | unsigned long logicalEnd; |
| 111 | }; |
| 112 | |
| 113 | /* |
| 114 | * Process the main store vpd to determine where the holes in memory are |
| 115 | * and return the number of physical blocks and fill in the array of |
| 116 | * block data. |
| 117 | */ |
| 118 | static unsigned long iSeries_process_Condor_mainstore_vpd( |
| 119 | struct MemoryBlock *mb_array, unsigned long max_entries) |
| 120 | { |
| 121 | unsigned long holeFirstChunk, holeSizeChunks; |
| 122 | unsigned long numMemoryBlocks = 1; |
| 123 | struct IoHriMainStoreSegment4 *msVpd = |
| 124 | (struct IoHriMainStoreSegment4 *)xMsVpd; |
| 125 | unsigned long holeStart = msVpd->nonInterleavedBlocksStartAdr; |
| 126 | unsigned long holeEnd = msVpd->nonInterleavedBlocksEndAdr; |
| 127 | unsigned long holeSize = holeEnd - holeStart; |
| 128 | |
| 129 | printk("Mainstore_VPD: Condor\n"); |
| 130 | /* |
| 131 | * Determine if absolute memory has any |
| 132 | * holes so that we can interpret the |
| 133 | * access map we get back from the hypervisor |
| 134 | * correctly. |
| 135 | */ |
| 136 | mb_array[0].logicalStart = 0; |
| 137 | mb_array[0].logicalEnd = 0x100000000; |
| 138 | mb_array[0].absStart = 0; |
| 139 | mb_array[0].absEnd = 0x100000000; |
| 140 | |
| 141 | if (holeSize) { |
| 142 | numMemoryBlocks = 2; |
| 143 | holeStart = holeStart & 0x000fffffffffffff; |
| 144 | holeStart = addr_to_chunk(holeStart); |
| 145 | holeFirstChunk = holeStart; |
| 146 | holeSize = addr_to_chunk(holeSize); |
| 147 | holeSizeChunks = holeSize; |
| 148 | printk( "Main store hole: start chunk = %0lx, size = %0lx chunks\n", |
| 149 | holeFirstChunk, holeSizeChunks ); |
| 150 | mb_array[0].logicalEnd = holeFirstChunk; |
| 151 | mb_array[0].absEnd = holeFirstChunk; |
| 152 | mb_array[1].logicalStart = holeFirstChunk; |
| 153 | mb_array[1].logicalEnd = 0x100000000 - holeSizeChunks; |
| 154 | mb_array[1].absStart = holeFirstChunk + holeSizeChunks; |
| 155 | mb_array[1].absEnd = 0x100000000; |
| 156 | } |
| 157 | return numMemoryBlocks; |
| 158 | } |
| 159 | |
| 160 | #define MaxSegmentAreas 32 |
| 161 | #define MaxSegmentAdrRangeBlocks 128 |
| 162 | #define MaxAreaRangeBlocks 4 |
| 163 | |
| 164 | static unsigned long iSeries_process_Regatta_mainstore_vpd( |
| 165 | struct MemoryBlock *mb_array, unsigned long max_entries) |
| 166 | { |
| 167 | struct IoHriMainStoreSegment5 *msVpdP = |
| 168 | (struct IoHriMainStoreSegment5 *)xMsVpd; |
| 169 | unsigned long numSegmentBlocks = 0; |
| 170 | u32 existsBits = msVpdP->msAreaExists; |
| 171 | unsigned long area_num; |
| 172 | |
| 173 | printk("Mainstore_VPD: Regatta\n"); |
| 174 | |
| 175 | for (area_num = 0; area_num < MaxSegmentAreas; ++area_num ) { |
| 176 | unsigned long numAreaBlocks; |
| 177 | struct IoHriMainStoreArea4 *currentArea; |
| 178 | |
| 179 | if (existsBits & 0x80000000) { |
| 180 | unsigned long block_num; |
| 181 | |
| 182 | currentArea = &msVpdP->msAreaArray[area_num]; |
| 183 | numAreaBlocks = currentArea->numAdrRangeBlocks; |
| 184 | printk("ms_vpd: processing area %2ld blocks=%ld", |
| 185 | area_num, numAreaBlocks); |
| 186 | for (block_num = 0; block_num < numAreaBlocks; |
| 187 | ++block_num ) { |
| 188 | /* Process an address range block */ |
| 189 | struct MemoryBlock tempBlock; |
| 190 | unsigned long i; |
| 191 | |
| 192 | tempBlock.absStart = |
| 193 | (unsigned long)currentArea->xAdrRangeBlock[block_num].blockStart; |
| 194 | tempBlock.absEnd = |
| 195 | (unsigned long)currentArea->xAdrRangeBlock[block_num].blockEnd; |
| 196 | tempBlock.logicalStart = 0; |
| 197 | tempBlock.logicalEnd = 0; |
| 198 | printk("\n block %ld absStart=%016lx absEnd=%016lx", |
| 199 | block_num, tempBlock.absStart, |
| 200 | tempBlock.absEnd); |
| 201 | |
| 202 | for (i = 0; i < numSegmentBlocks; ++i) { |
| 203 | if (mb_array[i].absStart == |
| 204 | tempBlock.absStart) |
| 205 | break; |
| 206 | } |
| 207 | if (i == numSegmentBlocks) { |
| 208 | if (numSegmentBlocks == max_entries) |
| 209 | panic("iSeries_process_mainstore_vpd: too many memory blocks"); |
| 210 | mb_array[numSegmentBlocks] = tempBlock; |
| 211 | ++numSegmentBlocks; |
| 212 | } else |
| 213 | printk(" (duplicate)"); |
| 214 | } |
| 215 | printk("\n"); |
| 216 | } |
| 217 | existsBits <<= 1; |
| 218 | } |
| 219 | /* Now sort the blocks found into ascending sequence */ |
| 220 | if (numSegmentBlocks > 1) { |
| 221 | unsigned long m, n; |
| 222 | |
| 223 | for (m = 0; m < numSegmentBlocks - 1; ++m) { |
| 224 | for (n = numSegmentBlocks - 1; m < n; --n) { |
| 225 | if (mb_array[n].absStart < |
| 226 | mb_array[n-1].absStart) { |
| 227 | struct MemoryBlock tempBlock; |
| 228 | |
| 229 | tempBlock = mb_array[n]; |
| 230 | mb_array[n] = mb_array[n-1]; |
| 231 | mb_array[n-1] = tempBlock; |
| 232 | } |
| 233 | } |
| 234 | } |
| 235 | } |
| 236 | /* |
| 237 | * Assign "logical" addresses to each block. These |
| 238 | * addresses correspond to the hypervisor "bitmap" space. |
| 239 | * Convert all addresses into units of 256K chunks. |
| 240 | */ |
| 241 | { |
| 242 | unsigned long i, nextBitmapAddress; |
| 243 | |
| 244 | printk("ms_vpd: %ld sorted memory blocks\n", numSegmentBlocks); |
| 245 | nextBitmapAddress = 0; |
| 246 | for (i = 0; i < numSegmentBlocks; ++i) { |
| 247 | unsigned long length = mb_array[i].absEnd - |
| 248 | mb_array[i].absStart; |
| 249 | |
| 250 | mb_array[i].logicalStart = nextBitmapAddress; |
| 251 | mb_array[i].logicalEnd = nextBitmapAddress + length; |
| 252 | nextBitmapAddress += length; |
| 253 | printk(" Bitmap range: %016lx - %016lx\n" |
| 254 | " Absolute range: %016lx - %016lx\n", |
| 255 | mb_array[i].logicalStart, |
| 256 | mb_array[i].logicalEnd, |
| 257 | mb_array[i].absStart, mb_array[i].absEnd); |
| 258 | mb_array[i].absStart = addr_to_chunk(mb_array[i].absStart & |
| 259 | 0x000fffffffffffff); |
| 260 | mb_array[i].absEnd = addr_to_chunk(mb_array[i].absEnd & |
| 261 | 0x000fffffffffffff); |
| 262 | mb_array[i].logicalStart = |
| 263 | addr_to_chunk(mb_array[i].logicalStart); |
| 264 | mb_array[i].logicalEnd = addr_to_chunk(mb_array[i].logicalEnd); |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | return numSegmentBlocks; |
| 269 | } |
| 270 | |
| 271 | static unsigned long iSeries_process_mainstore_vpd(struct MemoryBlock *mb_array, |
| 272 | unsigned long max_entries) |
| 273 | { |
| 274 | unsigned long i; |
| 275 | unsigned long mem_blocks = 0; |
| 276 | |
| 277 | if (cpu_has_feature(CPU_FTR_SLB)) |
| 278 | mem_blocks = iSeries_process_Regatta_mainstore_vpd(mb_array, |
| 279 | max_entries); |
| 280 | else |
| 281 | mem_blocks = iSeries_process_Condor_mainstore_vpd(mb_array, |
| 282 | max_entries); |
| 283 | |
| 284 | printk("Mainstore_VPD: numMemoryBlocks = %ld \n", mem_blocks); |
| 285 | for (i = 0; i < mem_blocks; ++i) { |
| 286 | printk("Mainstore_VPD: block %3ld logical chunks %016lx - %016lx\n" |
| 287 | " abs chunks %016lx - %016lx\n", |
| 288 | i, mb_array[i].logicalStart, mb_array[i].logicalEnd, |
| 289 | mb_array[i].absStart, mb_array[i].absEnd); |
| 290 | } |
| 291 | return mem_blocks; |
| 292 | } |
| 293 | |
| 294 | static void __init iSeries_get_cmdline(void) |
| 295 | { |
| 296 | char *p, *q; |
| 297 | |
| 298 | /* copy the command line parameter from the primary VSP */ |
| 299 | HvCallEvent_dmaToSp(cmd_line, 2 * 64* 1024, 256, |
| 300 | HvLpDma_Direction_RemoteToLocal); |
| 301 | |
| 302 | p = cmd_line; |
| 303 | q = cmd_line + 255; |
| 304 | while(p < q) { |
| 305 | if (!*p || *p == '\n') |
| 306 | break; |
| 307 | ++p; |
| 308 | } |
| 309 | *p = 0; |
| 310 | } |
| 311 | |
| 312 | static void __init iSeries_init_early(void) |
| 313 | { |
| 314 | extern unsigned long memory_limit; |
| 315 | |
| 316 | DBG(" -> iSeries_init_early()\n"); |
| 317 | |
Stephen Rothwell | aed3135 | 2005-08-03 14:43:21 +1000 | [diff] [blame] | 318 | ppc64_firmware_features = FW_FEATURE_ISERIES; |
| 319 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | ppcdbg_initialize(); |
| 321 | |
| 322 | #if defined(CONFIG_BLK_DEV_INITRD) |
| 323 | /* |
| 324 | * If the init RAM disk has been configured and there is |
| 325 | * a non-zero starting address for it, set it up |
| 326 | */ |
| 327 | if (naca.xRamDisk) { |
| 328 | initrd_start = (unsigned long)__va(naca.xRamDisk); |
| 329 | initrd_end = initrd_start + naca.xRamDiskSize * PAGE_SIZE; |
| 330 | initrd_below_start_ok = 1; // ramdisk in kernel space |
| 331 | ROOT_DEV = Root_RAM0; |
| 332 | if (((rd_size * 1024) / PAGE_SIZE) < naca.xRamDiskSize) |
| 333 | rd_size = (naca.xRamDiskSize * PAGE_SIZE) / 1024; |
| 334 | } else |
| 335 | #endif /* CONFIG_BLK_DEV_INITRD */ |
| 336 | { |
| 337 | /* ROOT_DEV = MKDEV(VIODASD_MAJOR, 1); */ |
| 338 | } |
| 339 | |
| 340 | iSeries_recal_tb = get_tb(); |
| 341 | iSeries_recal_titan = HvCallXm_loadTod(); |
| 342 | |
| 343 | /* |
| 344 | * Cache sizes must be initialized before hpte_init_iSeries is called |
| 345 | * as the later need them for flush_icache_range() |
| 346 | */ |
| 347 | setup_iSeries_cache_sizes(); |
| 348 | |
| 349 | /* |
| 350 | * Initialize the hash table management pointers |
| 351 | */ |
| 352 | hpte_init_iSeries(); |
| 353 | |
| 354 | /* |
| 355 | * Initialize the DMA/TCE management |
| 356 | */ |
| 357 | iommu_init_early_iSeries(); |
| 358 | |
| 359 | /* |
| 360 | * Initialize the table which translate Linux physical addresses to |
| 361 | * AS/400 absolute addresses |
| 362 | */ |
| 363 | build_iSeries_Memory_Map(); |
| 364 | |
| 365 | iSeries_get_cmdline(); |
| 366 | |
| 367 | /* Save unparsed command line copy for /proc/cmdline */ |
| 368 | strlcpy(saved_command_line, cmd_line, COMMAND_LINE_SIZE); |
| 369 | |
| 370 | /* Parse early parameters, in particular mem=x */ |
| 371 | parse_early_param(); |
| 372 | |
| 373 | if (memory_limit) { |
| 374 | if (memory_limit < systemcfg->physicalMemorySize) |
| 375 | systemcfg->physicalMemorySize = memory_limit; |
| 376 | else { |
| 377 | printk("Ignoring mem=%lu >= ram_top.\n", memory_limit); |
| 378 | memory_limit = 0; |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | /* Bolt kernel mappings for all of memory (or just a bit if we've got a limit) */ |
| 383 | iSeries_bolt_kernel(0, systemcfg->physicalMemorySize); |
| 384 | |
| 385 | lmb_init(); |
| 386 | lmb_add(0, systemcfg->physicalMemorySize); |
| 387 | lmb_analyze(); |
| 388 | lmb_reserve(0, __pa(klimit)); |
| 389 | |
| 390 | /* Initialize machine-dependency vectors */ |
| 391 | #ifdef CONFIG_SMP |
| 392 | smp_init_iSeries(); |
| 393 | #endif |
| 394 | if (itLpNaca.xPirEnvironMode == 0) |
| 395 | piranha_simulator = 1; |
| 396 | |
| 397 | /* Associate Lp Event Queue 0 with processor 0 */ |
| 398 | HvCallEvent_setLpEventQueueInterruptProc(0, 0); |
| 399 | |
| 400 | mf_init(); |
| 401 | mf_initialized = 1; |
| 402 | mb(); |
| 403 | |
| 404 | /* If we were passed an initrd, set the ROOT_DEV properly if the values |
| 405 | * look sensible. If not, clear initrd reference. |
| 406 | */ |
| 407 | #ifdef CONFIG_BLK_DEV_INITRD |
| 408 | if (initrd_start >= KERNELBASE && initrd_end >= KERNELBASE && |
| 409 | initrd_end > initrd_start) |
| 410 | ROOT_DEV = Root_RAM0; |
| 411 | else |
| 412 | initrd_start = initrd_end = 0; |
| 413 | #endif /* CONFIG_BLK_DEV_INITRD */ |
| 414 | |
| 415 | DBG(" <- iSeries_init_early()\n"); |
| 416 | } |
| 417 | |
Michael Ellerman | 56e97b7 | 2005-08-03 20:21:23 +1000 | [diff] [blame] | 418 | struct mschunks_map mschunks_map = { |
Michael Ellerman | 34c8f69 | 2005-08-03 20:21:23 +1000 | [diff] [blame] | 419 | /* XXX We don't use these, but Piranha might need them. */ |
| 420 | .chunk_size = MSCHUNKS_CHUNK_SIZE, |
| 421 | .chunk_shift = MSCHUNKS_CHUNK_SHIFT, |
| 422 | .chunk_mask = MSCHUNKS_OFFSET_MASK, |
| 423 | }; |
Michael Ellerman | 56e97b7 | 2005-08-03 20:21:23 +1000 | [diff] [blame] | 424 | EXPORT_SYMBOL(mschunks_map); |
Michael Ellerman | 34c8f69 | 2005-08-03 20:21:23 +1000 | [diff] [blame] | 425 | |
Michael Ellerman | 56e97b7 | 2005-08-03 20:21:23 +1000 | [diff] [blame] | 426 | void mschunks_alloc(unsigned long num_chunks) |
Michael Ellerman | 34c8f69 | 2005-08-03 20:21:23 +1000 | [diff] [blame] | 427 | { |
| 428 | klimit = _ALIGN(klimit, sizeof(u32)); |
Michael Ellerman | 56e97b7 | 2005-08-03 20:21:23 +1000 | [diff] [blame] | 429 | mschunks_map.mapping = (u32 *)klimit; |
Michael Ellerman | 34c8f69 | 2005-08-03 20:21:23 +1000 | [diff] [blame] | 430 | klimit += num_chunks * sizeof(u32); |
Michael Ellerman | 56e97b7 | 2005-08-03 20:21:23 +1000 | [diff] [blame] | 431 | mschunks_map.num_chunks = num_chunks; |
Michael Ellerman | 34c8f69 | 2005-08-03 20:21:23 +1000 | [diff] [blame] | 432 | } |
| 433 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 434 | /* |
| 435 | * The iSeries may have very large memories ( > 128 GB ) and a partition |
| 436 | * may get memory in "chunks" that may be anywhere in the 2**52 real |
| 437 | * address space. The chunks are 256K in size. To map this to the |
| 438 | * memory model Linux expects, the AS/400 specific code builds a |
| 439 | * translation table to translate what Linux thinks are "physical" |
| 440 | * addresses to the actual real addresses. This allows us to make |
| 441 | * it appear to Linux that we have contiguous memory starting at |
| 442 | * physical address zero while in fact this could be far from the truth. |
| 443 | * To avoid confusion, I'll let the words physical and/or real address |
| 444 | * apply to the Linux addresses while I'll use "absolute address" to |
| 445 | * refer to the actual hardware real address. |
| 446 | * |
| 447 | * build_iSeries_Memory_Map gets information from the Hypervisor and |
| 448 | * looks at the Main Store VPD to determine the absolute addresses |
| 449 | * of the memory that has been assigned to our partition and builds |
| 450 | * a table used to translate Linux's physical addresses to these |
| 451 | * absolute addresses. Absolute addresses are needed when |
| 452 | * communicating with the hypervisor (e.g. to build HPT entries) |
| 453 | */ |
| 454 | |
| 455 | static void __init build_iSeries_Memory_Map(void) |
| 456 | { |
| 457 | u32 loadAreaFirstChunk, loadAreaLastChunk, loadAreaSize; |
| 458 | u32 nextPhysChunk; |
| 459 | u32 hptFirstChunk, hptLastChunk, hptSizeChunks, hptSizePages; |
| 460 | u32 num_ptegs; |
| 461 | u32 totalChunks,moreChunks; |
| 462 | u32 currChunk, thisChunk, absChunk; |
| 463 | u32 currDword; |
| 464 | u32 chunkBit; |
| 465 | u64 map; |
| 466 | struct MemoryBlock mb[32]; |
| 467 | unsigned long numMemoryBlocks, curBlock; |
| 468 | |
| 469 | /* Chunk size on iSeries is 256K bytes */ |
| 470 | totalChunks = (u32)HvLpConfig_getMsChunks(); |
Michael Ellerman | 56e97b7 | 2005-08-03 20:21:23 +1000 | [diff] [blame] | 471 | mschunks_alloc(totalChunks); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 472 | |
| 473 | /* |
| 474 | * Get absolute address of our load area |
| 475 | * and map it to physical address 0 |
| 476 | * This guarantees that the loadarea ends up at physical 0 |
| 477 | * otherwise, it might not be returned by PLIC as the first |
| 478 | * chunks |
| 479 | */ |
| 480 | |
| 481 | loadAreaFirstChunk = (u32)addr_to_chunk(itLpNaca.xLoadAreaAddr); |
| 482 | loadAreaSize = itLpNaca.xLoadAreaChunks; |
| 483 | |
| 484 | /* |
| 485 | * Only add the pages already mapped here. |
| 486 | * Otherwise we might add the hpt pages |
| 487 | * The rest of the pages of the load area |
| 488 | * aren't in the HPT yet and can still |
| 489 | * be assigned an arbitrary physical address |
| 490 | */ |
| 491 | if ((loadAreaSize * 64) > HvPagesToMap) |
| 492 | loadAreaSize = HvPagesToMap / 64; |
| 493 | |
| 494 | loadAreaLastChunk = loadAreaFirstChunk + loadAreaSize - 1; |
| 495 | |
| 496 | /* |
| 497 | * TODO Do we need to do something if the HPT is in the 64MB load area? |
| 498 | * This would be required if the itLpNaca.xLoadAreaChunks includes |
| 499 | * the HPT size |
| 500 | */ |
| 501 | |
| 502 | printk("Mapping load area - physical addr = 0000000000000000\n" |
| 503 | " absolute addr = %016lx\n", |
| 504 | chunk_to_addr(loadAreaFirstChunk)); |
| 505 | printk("Load area size %dK\n", loadAreaSize * 256); |
| 506 | |
| 507 | for (nextPhysChunk = 0; nextPhysChunk < loadAreaSize; ++nextPhysChunk) |
Michael Ellerman | 56e97b7 | 2005-08-03 20:21:23 +1000 | [diff] [blame] | 508 | mschunks_map.mapping[nextPhysChunk] = |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 509 | loadAreaFirstChunk + nextPhysChunk; |
| 510 | |
| 511 | /* |
| 512 | * Get absolute address of our HPT and remember it so |
| 513 | * we won't map it to any physical address |
| 514 | */ |
| 515 | hptFirstChunk = (u32)addr_to_chunk(HvCallHpt_getHptAddress()); |
| 516 | hptSizePages = (u32)HvCallHpt_getHptPages(); |
Michael Ellerman | 34c8f69 | 2005-08-03 20:21:23 +1000 | [diff] [blame] | 517 | hptSizeChunks = hptSizePages >> (MSCHUNKS_CHUNK_SHIFT - PAGE_SHIFT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 518 | hptLastChunk = hptFirstChunk + hptSizeChunks - 1; |
| 519 | |
| 520 | printk("HPT absolute addr = %016lx, size = %dK\n", |
| 521 | chunk_to_addr(hptFirstChunk), hptSizeChunks * 256); |
| 522 | |
| 523 | /* Fill in the hashed page table hash mask */ |
| 524 | num_ptegs = hptSizePages * |
David Gibson | 96e2844 | 2005-07-13 01:11:42 -0700 | [diff] [blame] | 525 | (PAGE_SIZE / (sizeof(hpte_t) * HPTES_PER_GROUP)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | htab_hash_mask = num_ptegs - 1; |
| 527 | |
| 528 | /* |
| 529 | * The actual hashed page table is in the hypervisor, |
| 530 | * we have no direct access |
| 531 | */ |
| 532 | htab_address = NULL; |
| 533 | |
| 534 | /* |
| 535 | * Determine if absolute memory has any |
| 536 | * holes so that we can interpret the |
| 537 | * access map we get back from the hypervisor |
| 538 | * correctly. |
| 539 | */ |
| 540 | numMemoryBlocks = iSeries_process_mainstore_vpd(mb, 32); |
| 541 | |
| 542 | /* |
| 543 | * Process the main store access map from the hypervisor |
| 544 | * to build up our physical -> absolute translation table |
| 545 | */ |
| 546 | curBlock = 0; |
| 547 | currChunk = 0; |
| 548 | currDword = 0; |
| 549 | moreChunks = totalChunks; |
| 550 | |
| 551 | while (moreChunks) { |
| 552 | map = HvCallSm_get64BitsOfAccessMap(itLpNaca.xLpIndex, |
| 553 | currDword); |
| 554 | thisChunk = currChunk; |
| 555 | while (map) { |
| 556 | chunkBit = map >> 63; |
| 557 | map <<= 1; |
| 558 | if (chunkBit) { |
| 559 | --moreChunks; |
| 560 | while (thisChunk >= mb[curBlock].logicalEnd) { |
| 561 | ++curBlock; |
| 562 | if (curBlock >= numMemoryBlocks) |
| 563 | panic("out of memory blocks"); |
| 564 | } |
| 565 | if (thisChunk < mb[curBlock].logicalStart) |
| 566 | panic("memory block error"); |
| 567 | |
| 568 | absChunk = mb[curBlock].absStart + |
| 569 | (thisChunk - mb[curBlock].logicalStart); |
| 570 | if (((absChunk < hptFirstChunk) || |
| 571 | (absChunk > hptLastChunk)) && |
| 572 | ((absChunk < loadAreaFirstChunk) || |
| 573 | (absChunk > loadAreaLastChunk))) { |
Michael Ellerman | 56e97b7 | 2005-08-03 20:21:23 +1000 | [diff] [blame] | 574 | mschunks_map.mapping[nextPhysChunk] = |
| 575 | absChunk; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 576 | ++nextPhysChunk; |
| 577 | } |
| 578 | } |
| 579 | ++thisChunk; |
| 580 | } |
| 581 | ++currDword; |
| 582 | currChunk += 64; |
| 583 | } |
| 584 | |
| 585 | /* |
| 586 | * main store size (in chunks) is |
| 587 | * totalChunks - hptSizeChunks |
| 588 | * which should be equal to |
| 589 | * nextPhysChunk |
| 590 | */ |
| 591 | systemcfg->physicalMemorySize = chunk_to_addr(nextPhysChunk); |
| 592 | } |
| 593 | |
| 594 | /* |
| 595 | * Set up the variables that describe the cache line sizes |
| 596 | * for this machine. |
| 597 | */ |
| 598 | static void __init setup_iSeries_cache_sizes(void) |
| 599 | { |
| 600 | unsigned int i, n; |
| 601 | unsigned int procIx = get_paca()->lppaca.dyn_hv_phys_proc_index; |
| 602 | |
| 603 | systemcfg->icache_size = |
| 604 | ppc64_caches.isize = xIoHriProcessorVpd[procIx].xInstCacheSize * 1024; |
| 605 | systemcfg->icache_line_size = |
| 606 | ppc64_caches.iline_size = |
| 607 | xIoHriProcessorVpd[procIx].xInstCacheOperandSize; |
| 608 | systemcfg->dcache_size = |
| 609 | ppc64_caches.dsize = |
| 610 | xIoHriProcessorVpd[procIx].xDataL1CacheSizeKB * 1024; |
| 611 | systemcfg->dcache_line_size = |
| 612 | ppc64_caches.dline_size = |
| 613 | xIoHriProcessorVpd[procIx].xDataCacheOperandSize; |
| 614 | ppc64_caches.ilines_per_page = PAGE_SIZE / ppc64_caches.iline_size; |
| 615 | ppc64_caches.dlines_per_page = PAGE_SIZE / ppc64_caches.dline_size; |
| 616 | |
| 617 | i = ppc64_caches.iline_size; |
| 618 | n = 0; |
| 619 | while ((i = (i / 2))) |
| 620 | ++n; |
| 621 | ppc64_caches.log_iline_size = n; |
| 622 | |
| 623 | i = ppc64_caches.dline_size; |
| 624 | n = 0; |
| 625 | while ((i = (i / 2))) |
| 626 | ++n; |
| 627 | ppc64_caches.log_dline_size = n; |
| 628 | |
| 629 | printk("D-cache line size = %d\n", |
| 630 | (unsigned int)ppc64_caches.dline_size); |
| 631 | printk("I-cache line size = %d\n", |
| 632 | (unsigned int)ppc64_caches.iline_size); |
| 633 | } |
| 634 | |
| 635 | /* |
| 636 | * Create a pte. Used during initialization only. |
| 637 | */ |
| 638 | static void iSeries_make_pte(unsigned long va, unsigned long pa, |
| 639 | int mode) |
| 640 | { |
David Gibson | 96e2844 | 2005-07-13 01:11:42 -0700 | [diff] [blame] | 641 | hpte_t local_hpte, rhpte; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 642 | unsigned long hash, vpn; |
| 643 | long slot; |
| 644 | |
| 645 | vpn = va >> PAGE_SHIFT; |
| 646 | hash = hpt_hash(vpn, 0); |
| 647 | |
David Gibson | 96e2844 | 2005-07-13 01:11:42 -0700 | [diff] [blame] | 648 | local_hpte.r = pa | mode; |
| 649 | local_hpte.v = ((va >> 23) << HPTE_V_AVPN_SHIFT) |
| 650 | | HPTE_V_BOLTED | HPTE_V_VALID; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 651 | |
| 652 | slot = HvCallHpt_findValid(&rhpte, vpn); |
| 653 | if (slot < 0) { |
| 654 | /* Must find space in primary group */ |
| 655 | panic("hash_page: hpte already exists\n"); |
| 656 | } |
David Gibson | 96e2844 | 2005-07-13 01:11:42 -0700 | [diff] [blame] | 657 | HvCallHpt_addValidate(slot, 0, &local_hpte); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 658 | } |
| 659 | |
| 660 | /* |
| 661 | * Bolt the kernel addr space into the HPT |
| 662 | */ |
| 663 | static void __init iSeries_bolt_kernel(unsigned long saddr, unsigned long eaddr) |
| 664 | { |
| 665 | unsigned long pa; |
| 666 | unsigned long mode_rw = _PAGE_ACCESSED | _PAGE_COHERENT | PP_RWXX; |
David Gibson | 96e2844 | 2005-07-13 01:11:42 -0700 | [diff] [blame] | 667 | hpte_t hpte; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 668 | |
| 669 | for (pa = saddr; pa < eaddr ;pa += PAGE_SIZE) { |
| 670 | unsigned long ea = (unsigned long)__va(pa); |
| 671 | unsigned long vsid = get_kernel_vsid(ea); |
| 672 | unsigned long va = (vsid << 28) | (pa & 0xfffffff); |
| 673 | unsigned long vpn = va >> PAGE_SHIFT; |
| 674 | unsigned long slot = HvCallHpt_findValid(&hpte, vpn); |
| 675 | |
| 676 | /* Make non-kernel text non-executable */ |
| 677 | if (!in_kernel_text(ea)) |
| 678 | mode_rw |= HW_NO_EXEC; |
| 679 | |
David Gibson | 96e2844 | 2005-07-13 01:11:42 -0700 | [diff] [blame] | 680 | if (hpte.v & HPTE_V_VALID) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 681 | /* HPTE exists, so just bolt it */ |
| 682 | HvCallHpt_setSwBits(slot, 0x10, 0); |
| 683 | /* And make sure the pp bits are correct */ |
| 684 | HvCallHpt_setPp(slot, PP_RWXX); |
| 685 | } else |
| 686 | /* No HPTE exists, so create a new bolted one */ |
| 687 | iSeries_make_pte(va, phys_to_abs(pa), mode_rw); |
| 688 | } |
| 689 | } |
| 690 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 691 | /* |
| 692 | * Document me. |
| 693 | */ |
| 694 | static void __init iSeries_setup_arch(void) |
| 695 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 696 | unsigned procIx = get_paca()->lppaca.dyn_hv_phys_proc_index; |
| 697 | |
| 698 | /* Add an eye catcher and the systemcfg layout version number */ |
| 699 | strcpy(systemcfg->eye_catcher, "SYSTEMCFG:PPC64"); |
| 700 | systemcfg->version.major = SYSTEMCFG_MAJOR; |
| 701 | systemcfg->version.minor = SYSTEMCFG_MINOR; |
| 702 | |
| 703 | /* Setup the Lp Event Queue */ |
Michael Ellerman | 512d31d | 2005-06-30 15:08:27 +1000 | [diff] [blame] | 704 | setup_hvlpevent_queue(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 705 | |
| 706 | /* Compute processor frequency */ |
| 707 | procFreqHz = ((1UL << 34) * 1000000) / |
| 708 | xIoHriProcessorVpd[procIx].xProcFreq; |
| 709 | procFreqMhz = procFreqHz / 1000000; |
| 710 | procFreqMhzHundreths = (procFreqHz / 10000) - (procFreqMhz * 100); |
| 711 | ppc_proc_freq = procFreqHz; |
| 712 | |
| 713 | /* Compute time base frequency */ |
| 714 | tbFreqHz = ((1UL << 32) * 1000000) / |
| 715 | xIoHriProcessorVpd[procIx].xTimeBaseFreq; |
| 716 | tbFreqMhz = tbFreqHz / 1000000; |
| 717 | tbFreqMhzHundreths = (tbFreqHz / 10000) - (tbFreqMhz * 100); |
| 718 | ppc_tb_freq = tbFreqHz; |
| 719 | |
| 720 | printk("Max logical processors = %d\n", |
| 721 | itVpdAreas.xSlicMaxLogicalProcs); |
| 722 | printk("Max physical processors = %d\n", |
| 723 | itVpdAreas.xSlicMaxPhysicalProcs); |
| 724 | printk("Processor frequency = %lu.%02lu\n", procFreqMhz, |
| 725 | procFreqMhzHundreths); |
| 726 | printk("Time base frequency = %lu.%02lu\n", tbFreqMhz, |
| 727 | tbFreqMhzHundreths); |
| 728 | systemcfg->processor = xIoHriProcessorVpd[procIx].xPVR; |
| 729 | printk("Processor version = %x\n", systemcfg->processor); |
| 730 | } |
| 731 | |
| 732 | static void iSeries_get_cpuinfo(struct seq_file *m) |
| 733 | { |
| 734 | seq_printf(m, "machine\t\t: 64-bit iSeries Logical Partition\n"); |
| 735 | } |
| 736 | |
| 737 | /* |
| 738 | * Document me. |
| 739 | * and Implement me. |
| 740 | */ |
| 741 | static int iSeries_get_irq(struct pt_regs *regs) |
| 742 | { |
| 743 | /* -2 means ignore this interrupt */ |
| 744 | return -2; |
| 745 | } |
| 746 | |
| 747 | /* |
| 748 | * Document me. |
| 749 | */ |
| 750 | static void iSeries_restart(char *cmd) |
| 751 | { |
| 752 | mf_reboot(); |
| 753 | } |
| 754 | |
| 755 | /* |
| 756 | * Document me. |
| 757 | */ |
| 758 | static void iSeries_power_off(void) |
| 759 | { |
| 760 | mf_power_off(); |
| 761 | } |
| 762 | |
| 763 | /* |
| 764 | * Document me. |
| 765 | */ |
| 766 | static void iSeries_halt(void) |
| 767 | { |
| 768 | mf_power_off(); |
| 769 | } |
| 770 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 771 | /* |
| 772 | * void __init iSeries_calibrate_decr() |
| 773 | * |
| 774 | * Description: |
| 775 | * This routine retrieves the internal processor frequency from the VPD, |
| 776 | * and sets up the kernel timer decrementer based on that value. |
| 777 | * |
| 778 | */ |
| 779 | static void __init iSeries_calibrate_decr(void) |
| 780 | { |
| 781 | unsigned long cyclesPerUsec; |
| 782 | struct div_result divres; |
| 783 | |
| 784 | /* Compute decrementer (and TB) frequency in cycles/sec */ |
| 785 | cyclesPerUsec = ppc_tb_freq / 1000000; |
| 786 | |
| 787 | /* |
| 788 | * Set the amount to refresh the decrementer by. This |
| 789 | * is the number of decrementer ticks it takes for |
| 790 | * 1/HZ seconds. |
| 791 | */ |
| 792 | tb_ticks_per_jiffy = ppc_tb_freq / HZ; |
| 793 | |
| 794 | #if 0 |
| 795 | /* TEST CODE FOR ADJTIME */ |
| 796 | tb_ticks_per_jiffy += tb_ticks_per_jiffy / 5000; |
| 797 | /* END OF TEST CODE */ |
| 798 | #endif |
| 799 | |
| 800 | /* |
| 801 | * tb_ticks_per_sec = freq; would give better accuracy |
| 802 | * but tb_ticks_per_sec = tb_ticks_per_jiffy*HZ; assures |
| 803 | * that jiffies (and xtime) will match the time returned |
| 804 | * by do_gettimeofday. |
| 805 | */ |
| 806 | tb_ticks_per_sec = tb_ticks_per_jiffy * HZ; |
| 807 | tb_ticks_per_usec = cyclesPerUsec; |
| 808 | tb_to_us = mulhwu_scale_factor(ppc_tb_freq, 1000000); |
| 809 | div128_by_32(1024 * 1024, 0, tb_ticks_per_sec, &divres); |
| 810 | tb_to_xs = divres.result_low; |
| 811 | setup_default_decr(); |
| 812 | } |
| 813 | |
| 814 | static void __init iSeries_progress(char * st, unsigned short code) |
| 815 | { |
| 816 | printk("Progress: [%04x] - %s\n", (unsigned)code, st); |
| 817 | if (!piranha_simulator && mf_initialized) { |
| 818 | if (code != 0xffff) |
| 819 | mf_display_progress(code); |
| 820 | else |
| 821 | mf_clear_src(); |
| 822 | } |
| 823 | } |
| 824 | |
| 825 | static void __init iSeries_fixup_klimit(void) |
| 826 | { |
| 827 | /* |
| 828 | * Change klimit to take into account any ram disk |
| 829 | * that may be included |
| 830 | */ |
| 831 | if (naca.xRamDisk) |
| 832 | klimit = KERNELBASE + (u64)naca.xRamDisk + |
| 833 | (naca.xRamDiskSize * PAGE_SIZE); |
| 834 | else { |
| 835 | /* |
| 836 | * No ram disk was included - check and see if there |
| 837 | * was an embedded system map. Change klimit to take |
| 838 | * into account any embedded system map |
| 839 | */ |
| 840 | if (embedded_sysmap_end) |
| 841 | klimit = KERNELBASE + ((embedded_sysmap_end + 4095) & |
| 842 | 0xfffffffffffff000); |
| 843 | } |
| 844 | } |
| 845 | |
| 846 | static int __init iSeries_src_init(void) |
| 847 | { |
| 848 | /* clear the progress line */ |
| 849 | ppc_md.progress(" ", 0xffff); |
| 850 | return 0; |
| 851 | } |
| 852 | |
| 853 | late_initcall(iSeries_src_init); |
| 854 | |
Michael Ellerman | d200903 | 2005-07-07 17:56:29 -0700 | [diff] [blame] | 855 | static inline void process_iSeries_events(void) |
| 856 | { |
| 857 | asm volatile ("li 0,0x5555; sc" : : : "r0", "r3"); |
| 858 | } |
| 859 | |
| 860 | static void yield_shared_processor(void) |
| 861 | { |
| 862 | unsigned long tb; |
Michael Ellerman | d200903 | 2005-07-07 17:56:29 -0700 | [diff] [blame] | 863 | |
| 864 | HvCall_setEnabledInterrupts(HvCall_MaskIPI | |
| 865 | HvCall_MaskLpEvent | |
| 866 | HvCall_MaskLpProd | |
| 867 | HvCall_MaskTimeout); |
| 868 | |
| 869 | tb = get_tb(); |
| 870 | /* Compute future tb value when yield should expire */ |
| 871 | HvCall_yieldProcessor(HvCall_YieldTimed, tb+tb_ticks_per_jiffy); |
| 872 | |
Michael Ellerman | d200903 | 2005-07-07 17:56:29 -0700 | [diff] [blame] | 873 | /* |
| 874 | * The decrementer stops during the yield. Force a fake decrementer |
| 875 | * here and let the timer_interrupt code sort out the actual time. |
| 876 | */ |
| 877 | get_paca()->lppaca.int_dword.fields.decr_int = 1; |
| 878 | process_iSeries_events(); |
| 879 | } |
| 880 | |
Anton Blanchard | 3c57bb9 | 2005-07-07 17:56:32 -0700 | [diff] [blame] | 881 | static int iseries_shared_idle(void) |
Michael Ellerman | d200903 | 2005-07-07 17:56:29 -0700 | [diff] [blame] | 882 | { |
Anton Blanchard | 3c57bb9 | 2005-07-07 17:56:32 -0700 | [diff] [blame] | 883 | while (1) { |
| 884 | while (!need_resched() && !hvlpevent_is_pending()) { |
| 885 | local_irq_disable(); |
| 886 | ppc64_runlatch_off(); |
| 887 | |
| 888 | /* Recheck with irqs off */ |
| 889 | if (!need_resched() && !hvlpevent_is_pending()) |
| 890 | yield_shared_processor(); |
| 891 | |
| 892 | HMT_medium(); |
| 893 | local_irq_enable(); |
| 894 | } |
| 895 | |
| 896 | ppc64_runlatch_on(); |
| 897 | |
| 898 | if (hvlpevent_is_pending()) |
| 899 | process_iSeries_events(); |
| 900 | |
| 901 | schedule(); |
| 902 | } |
| 903 | |
| 904 | return 0; |
| 905 | } |
| 906 | |
| 907 | static int iseries_dedicated_idle(void) |
| 908 | { |
Michael Ellerman | d200903 | 2005-07-07 17:56:29 -0700 | [diff] [blame] | 909 | long oldval; |
| 910 | |
Michael Ellerman | d200903 | 2005-07-07 17:56:29 -0700 | [diff] [blame] | 911 | while (1) { |
Anton Blanchard | 3c57bb9 | 2005-07-07 17:56:32 -0700 | [diff] [blame] | 912 | oldval = test_and_clear_thread_flag(TIF_NEED_RESCHED); |
Michael Ellerman | d200903 | 2005-07-07 17:56:29 -0700 | [diff] [blame] | 913 | |
Anton Blanchard | 3c57bb9 | 2005-07-07 17:56:32 -0700 | [diff] [blame] | 914 | if (!oldval) { |
| 915 | set_thread_flag(TIF_POLLING_NRFLAG); |
Michael Ellerman | d200903 | 2005-07-07 17:56:29 -0700 | [diff] [blame] | 916 | |
Anton Blanchard | 3c57bb9 | 2005-07-07 17:56:32 -0700 | [diff] [blame] | 917 | while (!need_resched()) { |
| 918 | ppc64_runlatch_off(); |
| 919 | HMT_low(); |
| 920 | |
| 921 | if (hvlpevent_is_pending()) { |
Michael Ellerman | d200903 | 2005-07-07 17:56:29 -0700 | [diff] [blame] | 922 | HMT_medium(); |
Anton Blanchard | 3c57bb9 | 2005-07-07 17:56:32 -0700 | [diff] [blame] | 923 | ppc64_runlatch_on(); |
| 924 | process_iSeries_events(); |
Michael Ellerman | d200903 | 2005-07-07 17:56:29 -0700 | [diff] [blame] | 925 | } |
Michael Ellerman | d200903 | 2005-07-07 17:56:29 -0700 | [diff] [blame] | 926 | } |
Anton Blanchard | 3c57bb9 | 2005-07-07 17:56:32 -0700 | [diff] [blame] | 927 | |
| 928 | HMT_medium(); |
| 929 | clear_thread_flag(TIF_POLLING_NRFLAG); |
| 930 | } else { |
| 931 | set_need_resched(); |
Michael Ellerman | d200903 | 2005-07-07 17:56:29 -0700 | [diff] [blame] | 932 | } |
| 933 | |
| 934 | ppc64_runlatch_on(); |
| 935 | schedule(); |
Michael Ellerman | d200903 | 2005-07-07 17:56:29 -0700 | [diff] [blame] | 936 | } |
| 937 | |
| 938 | return 0; |
| 939 | } |
| 940 | |
Stephen Rothwell | 145d01e | 2005-06-21 17:15:52 -0700 | [diff] [blame] | 941 | #ifndef CONFIG_PCI |
| 942 | void __init iSeries_init_IRQ(void) { } |
| 943 | #endif |
| 944 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 945 | void __init iSeries_early_setup(void) |
| 946 | { |
| 947 | iSeries_fixup_klimit(); |
| 948 | |
| 949 | ppc_md.setup_arch = iSeries_setup_arch; |
| 950 | ppc_md.get_cpuinfo = iSeries_get_cpuinfo; |
| 951 | ppc_md.init_IRQ = iSeries_init_IRQ; |
| 952 | ppc_md.get_irq = iSeries_get_irq; |
| 953 | ppc_md.init_early = iSeries_init_early, |
| 954 | |
| 955 | ppc_md.pcibios_fixup = iSeries_pci_final_fixup; |
| 956 | |
| 957 | ppc_md.restart = iSeries_restart; |
| 958 | ppc_md.power_off = iSeries_power_off; |
| 959 | ppc_md.halt = iSeries_halt; |
| 960 | |
| 961 | ppc_md.get_boot_time = iSeries_get_boot_time; |
| 962 | ppc_md.set_rtc_time = iSeries_set_rtc_time; |
| 963 | ppc_md.get_rtc_time = iSeries_get_rtc_time; |
| 964 | ppc_md.calibrate_decr = iSeries_calibrate_decr; |
| 965 | ppc_md.progress = iSeries_progress; |
Anton Blanchard | 3c57bb9 | 2005-07-07 17:56:32 -0700 | [diff] [blame] | 966 | |
Michael Ellerman | 180a336 | 2005-08-09 11:13:36 +1000 | [diff] [blame] | 967 | /* XXX Implement enable_pmcs for iSeries */ |
| 968 | |
Michael Ellerman | b6bff39 | 2005-07-07 17:56:35 -0700 | [diff] [blame] | 969 | if (get_paca()->lppaca.shared_proc) { |
Anton Blanchard | 3c57bb9 | 2005-07-07 17:56:32 -0700 | [diff] [blame] | 970 | ppc_md.idle_loop = iseries_shared_idle; |
Michael Ellerman | b6bff39 | 2005-07-07 17:56:35 -0700 | [diff] [blame] | 971 | printk(KERN_INFO "Using shared processor idle loop\n"); |
| 972 | } else { |
Anton Blanchard | 3c57bb9 | 2005-07-07 17:56:32 -0700 | [diff] [blame] | 973 | ppc_md.idle_loop = iseries_dedicated_idle; |
Michael Ellerman | b6bff39 | 2005-07-07 17:56:35 -0700 | [diff] [blame] | 974 | printk(KERN_INFO "Using dedicated idle loop\n"); |
| 975 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 976 | } |
| 977 | |