setup.c 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532
  1. /*
  2. * linux/arch/alpha/kernel/setup.c
  3. *
  4. * Copyright (C) 1995 Linus Torvalds
  5. */
  6. /* 2.3.x bootmem, 1999 Andrea Arcangeli <andrea@suse.de> */
  7. /*
  8. * Bootup setup stuff.
  9. */
  10. #include <linux/sched.h>
  11. #include <linux/kernel.h>
  12. #include <linux/mm.h>
  13. #include <linux/stddef.h>
  14. #include <linux/unistd.h>
  15. #include <linux/ptrace.h>
  16. #include <linux/slab.h>
  17. #include <linux/user.h>
  18. #include <linux/screen_info.h>
  19. #include <linux/delay.h>
  20. #include <linux/mc146818rtc.h>
  21. #include <linux/console.h>
  22. #include <linux/cpu.h>
  23. #include <linux/errno.h>
  24. #include <linux/init.h>
  25. #include <linux/string.h>
  26. #include <linux/ioport.h>
  27. #include <linux/platform_device.h>
  28. #include <linux/bootmem.h>
  29. #include <linux/pci.h>
  30. #include <linux/seq_file.h>
  31. #include <linux/root_dev.h>
  32. #include <linux/initrd.h>
  33. #include <linux/eisa.h>
  34. #include <linux/pfn.h>
  35. #ifdef CONFIG_MAGIC_SYSRQ
  36. #include <linux/sysrq.h>
  37. #include <linux/reboot.h>
  38. #endif
  39. #include <linux/notifier.h>
  40. #include <asm/setup.h>
  41. #include <asm/io.h>
  42. #include <linux/log2.h>
  43. #include <linux/export.h>
  44. extern struct atomic_notifier_head panic_notifier_list;
  45. static int alpha_panic_event(struct notifier_block *, unsigned long, void *);
  46. static struct notifier_block alpha_panic_block = {
  47. alpha_panic_event,
  48. NULL,
  49. INT_MAX /* try to do it first */
  50. };
  51. #include <asm/uaccess.h>
  52. #include <asm/pgtable.h>
  53. #include <asm/hwrpb.h>
  54. #include <asm/dma.h>
  55. #include <asm/mmu_context.h>
  56. #include <asm/console.h>
  57. #include "proto.h"
  58. #include "pci_impl.h"
  59. struct hwrpb_struct *hwrpb;
  60. EXPORT_SYMBOL(hwrpb);
  61. unsigned long srm_hae;
  62. int alpha_l1i_cacheshape;
  63. int alpha_l1d_cacheshape;
  64. int alpha_l2_cacheshape;
  65. int alpha_l3_cacheshape;
  66. #ifdef CONFIG_VERBOSE_MCHECK
  67. /* 0=minimum, 1=verbose, 2=all */
  68. /* These can be overridden via the command line, ie "verbose_mcheck=2") */
  69. unsigned long alpha_verbose_mcheck = CONFIG_VERBOSE_MCHECK_ON;
  70. #endif
  71. #ifdef CONFIG_NUMA
  72. struct cpumask node_to_cpumask_map[MAX_NUMNODES] __read_mostly;
  73. EXPORT_SYMBOL(node_to_cpumask_map);
  74. #endif
  75. /* Which processor we booted from. */
  76. int boot_cpuid;
  77. /*
  78. * Using SRM callbacks for initial console output. This works from
  79. * setup_arch() time through the end of time_init(), as those places
  80. * are under our (Alpha) control.
  81. * "srmcons" specified in the boot command arguments allows us to
  82. * see kernel messages during the period of time before the true
  83. * console device is "registered" during console_init().
  84. * As of this version (2.5.59), console_init() will call
  85. * disable_early_printk() as the last action before initializing
  86. * the console drivers. That's the last possible time srmcons can be
  87. * unregistered without interfering with console behavior.
  88. *
  89. * By default, OFF; set it with a bootcommand arg of "srmcons" or
  90. * "console=srm". The meaning of these two args is:
  91. * "srmcons" - early callback prints
  92. * "console=srm" - full callback based console, including early prints
  93. */
  94. int srmcons_output = 0;
  95. /* Enforce a memory size limit; useful for testing. By default, none. */
  96. unsigned long mem_size_limit = 0;
  97. /* Set AGP GART window size (0 means disabled). */
  98. unsigned long alpha_agpgart_size = DEFAULT_AGP_APER_SIZE;
  99. #ifdef CONFIG_ALPHA_GENERIC
  100. struct alpha_machine_vector alpha_mv;
  101. #endif
  102. #ifndef alpha_using_srm
  103. int alpha_using_srm;
  104. EXPORT_SYMBOL(alpha_using_srm);
  105. #endif
  106. #ifndef alpha_using_qemu
  107. int alpha_using_qemu;
  108. #endif
  109. static struct alpha_machine_vector *get_sysvec(unsigned long, unsigned long,
  110. unsigned long);
  111. static struct alpha_machine_vector *get_sysvec_byname(const char *);
  112. static void get_sysnames(unsigned long, unsigned long, unsigned long,
  113. char **, char **);
  114. static void determine_cpu_caches (unsigned int);
  115. static char __initdata command_line[COMMAND_LINE_SIZE];
  116. /*
  117. * The format of "screen_info" is strange, and due to early
  118. * i386-setup code. This is just enough to make the console
  119. * code think we're on a VGA color display.
  120. */
  121. struct screen_info screen_info = {
  122. .orig_x = 0,
  123. .orig_y = 25,
  124. .orig_video_cols = 80,
  125. .orig_video_lines = 25,
  126. .orig_video_isVGA = 1,
  127. .orig_video_points = 16
  128. };
  129. EXPORT_SYMBOL(screen_info);
  130. /*
  131. * The direct map I/O window, if any. This should be the same
  132. * for all busses, since it's used by virt_to_bus.
  133. */
  134. unsigned long __direct_map_base;
  135. unsigned long __direct_map_size;
  136. EXPORT_SYMBOL(__direct_map_base);
  137. EXPORT_SYMBOL(__direct_map_size);
  138. /*
  139. * Declare all of the machine vectors.
  140. */
  141. /* GCC 2.7.2 (on alpha at least) is lame. It does not support either
  142. __attribute__((weak)) or #pragma weak. Bypass it and talk directly
  143. to the assembler. */
  144. #define WEAK(X) \
  145. extern struct alpha_machine_vector X; \
  146. asm(".weak "#X)
  147. WEAK(alcor_mv);
  148. WEAK(alphabook1_mv);
  149. WEAK(avanti_mv);
  150. WEAK(cabriolet_mv);
  151. WEAK(clipper_mv);
  152. WEAK(dp264_mv);
  153. WEAK(eb164_mv);
  154. WEAK(eb64p_mv);
  155. WEAK(eb66_mv);
  156. WEAK(eb66p_mv);
  157. WEAK(eiger_mv);
  158. WEAK(jensen_mv);
  159. WEAK(lx164_mv);
  160. WEAK(lynx_mv);
  161. WEAK(marvel_ev7_mv);
  162. WEAK(miata_mv);
  163. WEAK(mikasa_mv);
  164. WEAK(mikasa_primo_mv);
  165. WEAK(monet_mv);
  166. WEAK(nautilus_mv);
  167. WEAK(noname_mv);
  168. WEAK(noritake_mv);
  169. WEAK(noritake_primo_mv);
  170. WEAK(p2k_mv);
  171. WEAK(pc164_mv);
  172. WEAK(privateer_mv);
  173. WEAK(rawhide_mv);
  174. WEAK(ruffian_mv);
  175. WEAK(rx164_mv);
  176. WEAK(sable_mv);
  177. WEAK(sable_gamma_mv);
  178. WEAK(shark_mv);
  179. WEAK(sx164_mv);
  180. WEAK(takara_mv);
  181. WEAK(titan_mv);
  182. WEAK(webbrick_mv);
  183. WEAK(wildfire_mv);
  184. WEAK(xl_mv);
  185. WEAK(xlt_mv);
  186. #undef WEAK
  187. /*
  188. * I/O resources inherited from PeeCees. Except for perhaps the
  189. * turbochannel alphas, everyone has these on some sort of SuperIO chip.
  190. *
  191. * ??? If this becomes less standard, move the struct out into the
  192. * machine vector.
  193. */
  194. static void __init
  195. reserve_std_resources(void)
  196. {
  197. static struct resource standard_io_resources[] = {
  198. { .name = "rtc", .start = -1, .end = -1 },
  199. { .name = "dma1", .start = 0x00, .end = 0x1f },
  200. { .name = "pic1", .start = 0x20, .end = 0x3f },
  201. { .name = "timer", .start = 0x40, .end = 0x5f },
  202. { .name = "keyboard", .start = 0x60, .end = 0x6f },
  203. { .name = "dma page reg", .start = 0x80, .end = 0x8f },
  204. { .name = "pic2", .start = 0xa0, .end = 0xbf },
  205. { .name = "dma2", .start = 0xc0, .end = 0xdf },
  206. };
  207. struct resource *io = &ioport_resource;
  208. size_t i;
  209. if (hose_head) {
  210. struct pci_controller *hose;
  211. for (hose = hose_head; hose; hose = hose->next)
  212. if (hose->index == 0) {
  213. io = hose->io_space;
  214. break;
  215. }
  216. }
  217. /* Fix up for the Jensen's queer RTC placement. */
  218. standard_io_resources[0].start = RTC_PORT(0);
  219. standard_io_resources[0].end = RTC_PORT(0) + 0x10;
  220. for (i = 0; i < ARRAY_SIZE(standard_io_resources); ++i)
  221. request_resource(io, standard_io_resources+i);
  222. }
  223. #define PFN_MAX PFN_DOWN(0x80000000)
  224. #define for_each_mem_cluster(memdesc, _cluster, i) \
  225. for ((_cluster) = (memdesc)->cluster, (i) = 0; \
  226. (i) < (memdesc)->numclusters; (i)++, (_cluster)++)
  227. static unsigned long __init
  228. get_mem_size_limit(char *s)
  229. {
  230. unsigned long end = 0;
  231. char *from = s;
  232. end = simple_strtoul(from, &from, 0);
  233. if ( *from == 'K' || *from == 'k' ) {
  234. end = end << 10;
  235. from++;
  236. } else if ( *from == 'M' || *from == 'm' ) {
  237. end = end << 20;
  238. from++;
  239. } else if ( *from == 'G' || *from == 'g' ) {
  240. end = end << 30;
  241. from++;
  242. }
  243. return end >> PAGE_SHIFT; /* Return the PFN of the limit. */
  244. }
  245. #ifdef CONFIG_BLK_DEV_INITRD
  246. void * __init
  247. move_initrd(unsigned long mem_limit)
  248. {
  249. void *start;
  250. unsigned long size;
  251. size = initrd_end - initrd_start;
  252. start = __alloc_bootmem(PAGE_ALIGN(size), PAGE_SIZE, 0);
  253. if (!start || __pa(start) + size > mem_limit) {
  254. initrd_start = initrd_end = 0;
  255. return NULL;
  256. }
  257. memmove(start, (void *)initrd_start, size);
  258. initrd_start = (unsigned long)start;
  259. initrd_end = initrd_start + size;
  260. printk("initrd moved to %p\n", start);
  261. return start;
  262. }
  263. #endif
  264. #ifndef CONFIG_DISCONTIGMEM
  265. static void __init
  266. setup_memory(void *kernel_end)
  267. {
  268. struct memclust_struct * cluster;
  269. struct memdesc_struct * memdesc;
  270. unsigned long start_kernel_pfn, end_kernel_pfn;
  271. unsigned long bootmap_size, bootmap_pages, bootmap_start;
  272. unsigned long start, end;
  273. unsigned long i;
  274. /* Find free clusters, and init and free the bootmem accordingly. */
  275. memdesc = (struct memdesc_struct *)
  276. (hwrpb->mddt_offset + (unsigned long) hwrpb);
  277. for_each_mem_cluster(memdesc, cluster, i) {
  278. printk("memcluster %lu, usage %01lx, start %8lu, end %8lu\n",
  279. i, cluster->usage, cluster->start_pfn,
  280. cluster->start_pfn + cluster->numpages);
  281. /* Bit 0 is console/PALcode reserved. Bit 1 is
  282. non-volatile memory -- we might want to mark
  283. this for later. */
  284. if (cluster->usage & 3)
  285. continue;
  286. end = cluster->start_pfn + cluster->numpages;
  287. if (end > max_low_pfn)
  288. max_low_pfn = end;
  289. }
  290. /*
  291. * Except for the NUMA systems (wildfire, marvel) all of the
  292. * Alpha systems we run on support 32GB of memory or less.
  293. * Since the NUMA systems introduce large holes in memory addressing,
  294. * we can get into a situation where there is not enough contiguous
  295. * memory for the memory map.
  296. *
  297. * Limit memory to the first 32GB to limit the NUMA systems to
  298. * memory on their first node (wildfire) or 2 (marvel) to avoid
  299. * not being able to produce the memory map. In order to access
  300. * all of the memory on the NUMA systems, build with discontiguous
  301. * memory support.
  302. *
  303. * If the user specified a memory limit, let that memory limit stand.
  304. */
  305. if (!mem_size_limit)
  306. mem_size_limit = (32ul * 1024 * 1024 * 1024) >> PAGE_SHIFT;
  307. if (mem_size_limit && max_low_pfn >= mem_size_limit)
  308. {
  309. printk("setup: forcing memory size to %ldK (from %ldK).\n",
  310. mem_size_limit << (PAGE_SHIFT - 10),
  311. max_low_pfn << (PAGE_SHIFT - 10));
  312. max_low_pfn = mem_size_limit;
  313. }
  314. /* Find the bounds of kernel memory. */
  315. start_kernel_pfn = PFN_DOWN(KERNEL_START_PHYS);
  316. end_kernel_pfn = PFN_UP(virt_to_phys(kernel_end));
  317. bootmap_start = -1;
  318. try_again:
  319. if (max_low_pfn <= end_kernel_pfn)
  320. panic("not enough memory to boot");
  321. /* We need to know how many physically contiguous pages
  322. we'll need for the bootmap. */
  323. bootmap_pages = bootmem_bootmap_pages(max_low_pfn);
  324. /* Now find a good region where to allocate the bootmap. */
  325. for_each_mem_cluster(memdesc, cluster, i) {
  326. if (cluster->usage & 3)
  327. continue;
  328. start = cluster->start_pfn;
  329. end = start + cluster->numpages;
  330. if (start >= max_low_pfn)
  331. continue;
  332. if (end > max_low_pfn)
  333. end = max_low_pfn;
  334. if (start < start_kernel_pfn) {
  335. if (end > end_kernel_pfn
  336. && end - end_kernel_pfn >= bootmap_pages) {
  337. bootmap_start = end_kernel_pfn;
  338. break;
  339. } else if (end > start_kernel_pfn)
  340. end = start_kernel_pfn;
  341. } else if (start < end_kernel_pfn)
  342. start = end_kernel_pfn;
  343. if (end - start >= bootmap_pages) {
  344. bootmap_start = start;
  345. break;
  346. }
  347. }
  348. if (bootmap_start == ~0UL) {
  349. max_low_pfn >>= 1;
  350. goto try_again;
  351. }
  352. /* Allocate the bootmap and mark the whole MM as reserved. */
  353. bootmap_size = init_bootmem(bootmap_start, max_low_pfn);
  354. /* Mark the free regions. */
  355. for_each_mem_cluster(memdesc, cluster, i) {
  356. if (cluster->usage & 3)
  357. continue;
  358. start = cluster->start_pfn;
  359. end = cluster->start_pfn + cluster->numpages;
  360. if (start >= max_low_pfn)
  361. continue;
  362. if (end > max_low_pfn)
  363. end = max_low_pfn;
  364. if (start < start_kernel_pfn) {
  365. if (end > end_kernel_pfn) {
  366. free_bootmem(PFN_PHYS(start),
  367. (PFN_PHYS(start_kernel_pfn)
  368. - PFN_PHYS(start)));
  369. printk("freeing pages %ld:%ld\n",
  370. start, start_kernel_pfn);
  371. start = end_kernel_pfn;
  372. } else if (end > start_kernel_pfn)
  373. end = start_kernel_pfn;
  374. } else if (start < end_kernel_pfn)
  375. start = end_kernel_pfn;
  376. if (start >= end)
  377. continue;
  378. free_bootmem(PFN_PHYS(start), PFN_PHYS(end) - PFN_PHYS(start));
  379. printk("freeing pages %ld:%ld\n", start, end);
  380. }
  381. /* Reserve the bootmap memory. */
  382. reserve_bootmem(PFN_PHYS(bootmap_start), bootmap_size,
  383. BOOTMEM_DEFAULT);
  384. printk("reserving pages %ld:%ld\n", bootmap_start, bootmap_start+PFN_UP(bootmap_size));
  385. #ifdef CONFIG_BLK_DEV_INITRD
  386. initrd_start = INITRD_START;
  387. if (initrd_start) {
  388. initrd_end = initrd_start+INITRD_SIZE;
  389. printk("Initial ramdisk at: 0x%p (%lu bytes)\n",
  390. (void *) initrd_start, INITRD_SIZE);
  391. if ((void *)initrd_end > phys_to_virt(PFN_PHYS(max_low_pfn))) {
  392. if (!move_initrd(PFN_PHYS(max_low_pfn)))
  393. printk("initrd extends beyond end of memory "
  394. "(0x%08lx > 0x%p)\ndisabling initrd\n",
  395. initrd_end,
  396. phys_to_virt(PFN_PHYS(max_low_pfn)));
  397. } else {
  398. reserve_bootmem(virt_to_phys((void *)initrd_start),
  399. INITRD_SIZE, BOOTMEM_DEFAULT);
  400. }
  401. }
  402. #endif /* CONFIG_BLK_DEV_INITRD */
  403. }
  404. #else
  405. extern void setup_memory(void *);
  406. #endif /* !CONFIG_DISCONTIGMEM */
  407. int __init
  408. page_is_ram(unsigned long pfn)
  409. {
  410. struct memclust_struct * cluster;
  411. struct memdesc_struct * memdesc;
  412. unsigned long i;
  413. memdesc = (struct memdesc_struct *)
  414. (hwrpb->mddt_offset + (unsigned long) hwrpb);
  415. for_each_mem_cluster(memdesc, cluster, i)
  416. {
  417. if (pfn >= cluster->start_pfn &&
  418. pfn < cluster->start_pfn + cluster->numpages) {
  419. return (cluster->usage & 3) ? 0 : 1;
  420. }
  421. }
  422. return 0;
  423. }
  424. static int __init
  425. register_cpus(void)
  426. {
  427. int i;
  428. for_each_possible_cpu(i) {
  429. struct cpu *p = kzalloc(sizeof(*p), GFP_KERNEL);
  430. if (!p)
  431. return -ENOMEM;
  432. register_cpu(p, i);
  433. }
  434. return 0;
  435. }
  436. arch_initcall(register_cpus);
  437. void __init
  438. setup_arch(char **cmdline_p)
  439. {
  440. extern char _end[];
  441. struct alpha_machine_vector *vec = NULL;
  442. struct percpu_struct *cpu;
  443. char *type_name, *var_name, *p;
  444. void *kernel_end = _end; /* end of kernel */
  445. char *args = command_line;
  446. hwrpb = (struct hwrpb_struct*) __va(INIT_HWRPB->phys_addr);
  447. boot_cpuid = hard_smp_processor_id();
  448. /*
  449. * Pre-process the system type to make sure it will be valid.
  450. *
  451. * This may restore real CABRIO and EB66+ family names, ie
  452. * EB64+ and EB66.
  453. *
  454. * Oh, and "white box" AS800 (aka DIGITAL Server 3000 series)
  455. * and AS1200 (DIGITAL Server 5000 series) have the type as
  456. * the negative of the real one.
  457. */
  458. if ((long)hwrpb->sys_type < 0) {
  459. hwrpb->sys_type = -((long)hwrpb->sys_type);
  460. hwrpb_update_checksum(hwrpb);
  461. }
  462. /* Register a call for panic conditions. */
  463. atomic_notifier_chain_register(&panic_notifier_list,
  464. &alpha_panic_block);
  465. #ifndef alpha_using_srm
  466. /* Assume that we've booted from SRM if we haven't booted from MILO.
  467. Detect the later by looking for "MILO" in the system serial nr. */
  468. alpha_using_srm = strncmp((const char *)hwrpb->ssn, "MILO", 4) != 0;
  469. #endif
  470. #ifndef alpha_using_qemu
  471. /* Similarly, look for QEMU. */
  472. alpha_using_qemu = strstr((const char *)hwrpb->ssn, "QEMU") != 0;
  473. #endif
  474. /* If we are using SRM, we want to allow callbacks
  475. as early as possible, so do this NOW, and then
  476. they should work immediately thereafter.
  477. */
  478. kernel_end = callback_init(kernel_end);
  479. /*
  480. * Locate the command line.
  481. */
  482. /* Hack for Jensen... since we're restricted to 8 or 16 chars for
  483. boot flags depending on the boot mode, we need some shorthand.
  484. This should do for installation. */
  485. if (strcmp(COMMAND_LINE, "INSTALL") == 0) {
  486. strlcpy(command_line, "root=/dev/fd0 load_ramdisk=1", sizeof command_line);
  487. } else {
  488. strlcpy(command_line, COMMAND_LINE, sizeof command_line);
  489. }
  490. strcpy(boot_command_line, command_line);
  491. *cmdline_p = command_line;
  492. /*
  493. * Process command-line arguments.
  494. */
  495. while ((p = strsep(&args, " \t")) != NULL) {
  496. if (!*p) continue;
  497. if (strncmp(p, "alpha_mv=", 9) == 0) {
  498. vec = get_sysvec_byname(p+9);
  499. continue;
  500. }
  501. if (strncmp(p, "cycle=", 6) == 0) {
  502. est_cycle_freq = simple_strtol(p+6, NULL, 0);
  503. continue;
  504. }
  505. if (strncmp(p, "mem=", 4) == 0) {
  506. mem_size_limit = get_mem_size_limit(p+4);
  507. continue;
  508. }
  509. if (strncmp(p, "srmcons", 7) == 0) {
  510. srmcons_output |= 1;
  511. continue;
  512. }
  513. if (strncmp(p, "console=srm", 11) == 0) {
  514. srmcons_output |= 2;
  515. continue;
  516. }
  517. if (strncmp(p, "gartsize=", 9) == 0) {
  518. alpha_agpgart_size =
  519. get_mem_size_limit(p+9) << PAGE_SHIFT;
  520. continue;
  521. }
  522. #ifdef CONFIG_VERBOSE_MCHECK
  523. if (strncmp(p, "verbose_mcheck=", 15) == 0) {
  524. alpha_verbose_mcheck = simple_strtol(p+15, NULL, 0);
  525. continue;
  526. }
  527. #endif
  528. }
  529. /* Replace the command line, now that we've killed it with strsep. */
  530. strcpy(command_line, boot_command_line);
  531. /* If we want SRM console printk echoing early, do it now. */
  532. if (alpha_using_srm && srmcons_output) {
  533. register_srm_console();
  534. /*
  535. * If "console=srm" was specified, clear the srmcons_output
  536. * flag now so that time.c won't unregister_srm_console
  537. */
  538. if (srmcons_output & 2)
  539. srmcons_output = 0;
  540. }
  541. #ifdef CONFIG_MAGIC_SYSRQ
  542. /* If we're using SRM, make sysrq-b halt back to the prom,
  543. not auto-reboot. */
  544. if (alpha_using_srm) {
  545. struct sysrq_key_op *op = __sysrq_get_key_op('b');
  546. op->handler = (void *) machine_halt;
  547. }
  548. #endif
  549. /*
  550. * Identify and reconfigure for the current system.
  551. */
  552. cpu = (struct percpu_struct*)((char*)hwrpb + hwrpb->processor_offset);
  553. get_sysnames(hwrpb->sys_type, hwrpb->sys_variation,
  554. cpu->type, &type_name, &var_name);
  555. if (*var_name == '0')
  556. var_name = "";
  557. if (!vec) {
  558. vec = get_sysvec(hwrpb->sys_type, hwrpb->sys_variation,
  559. cpu->type);
  560. }
  561. if (!vec) {
  562. panic("Unsupported system type: %s%s%s (%ld %ld)\n",
  563. type_name, (*var_name ? " variation " : ""), var_name,
  564. hwrpb->sys_type, hwrpb->sys_variation);
  565. }
  566. if (vec != &alpha_mv) {
  567. alpha_mv = *vec;
  568. }
  569. printk("Booting "
  570. #ifdef CONFIG_ALPHA_GENERIC
  571. "GENERIC "
  572. #endif
  573. "on %s%s%s using machine vector %s from %s\n",
  574. type_name, (*var_name ? " variation " : ""),
  575. var_name, alpha_mv.vector_name,
  576. (alpha_using_srm ? "SRM" : "MILO"));
  577. printk("Major Options: "
  578. #ifdef CONFIG_SMP
  579. "SMP "
  580. #endif
  581. #ifdef CONFIG_ALPHA_EV56
  582. "EV56 "
  583. #endif
  584. #ifdef CONFIG_ALPHA_EV67
  585. "EV67 "
  586. #endif
  587. #ifdef CONFIG_ALPHA_LEGACY_START_ADDRESS
  588. "LEGACY_START "
  589. #endif
  590. #ifdef CONFIG_VERBOSE_MCHECK
  591. "VERBOSE_MCHECK "
  592. #endif
  593. #ifdef CONFIG_DISCONTIGMEM
  594. "DISCONTIGMEM "
  595. #ifdef CONFIG_NUMA
  596. "NUMA "
  597. #endif
  598. #endif
  599. #ifdef CONFIG_DEBUG_SPINLOCK
  600. "DEBUG_SPINLOCK "
  601. #endif
  602. #ifdef CONFIG_MAGIC_SYSRQ
  603. "MAGIC_SYSRQ "
  604. #endif
  605. "\n");
  606. printk("Command line: %s\n", command_line);
  607. /*
  608. * Sync up the HAE.
  609. * Save the SRM's current value for restoration.
  610. */
  611. srm_hae = *alpha_mv.hae_register;
  612. __set_hae(alpha_mv.hae_cache);
  613. /* Reset enable correctable error reports. */
  614. wrmces(0x7);
  615. /* Find our memory. */
  616. setup_memory(kernel_end);
  617. /* First guess at cpu cache sizes. Do this before init_arch. */
  618. determine_cpu_caches(cpu->type);
  619. /* Initialize the machine. Usually has to do with setting up
  620. DMA windows and the like. */
  621. if (alpha_mv.init_arch)
  622. alpha_mv.init_arch();
  623. /* Reserve standard resources. */
  624. reserve_std_resources();
  625. /*
  626. * Give us a default console. TGA users will see nothing until
  627. * chr_dev_init is called, rather late in the boot sequence.
  628. */
  629. #ifdef CONFIG_VT
  630. #if defined(CONFIG_VGA_CONSOLE)
  631. conswitchp = &vga_con;
  632. #elif defined(CONFIG_DUMMY_CONSOLE)
  633. conswitchp = &dummy_con;
  634. #endif
  635. #endif
  636. /* Default root filesystem to sda2. */
  637. ROOT_DEV = Root_SDA2;
  638. #ifdef CONFIG_EISA
  639. /* FIXME: only set this when we actually have EISA in this box? */
  640. EISA_bus = 1;
  641. #endif
  642. /*
  643. * Check ASN in HWRPB for validity, report if bad.
  644. * FIXME: how was this failing? Should we trust it instead,
  645. * and copy the value into alpha_mv.max_asn?
  646. */
  647. if (hwrpb->max_asn != MAX_ASN) {
  648. printk("Max ASN from HWRPB is bad (0x%lx)\n", hwrpb->max_asn);
  649. }
  650. /*
  651. * Identify the flock of penguins.
  652. */
  653. #ifdef CONFIG_SMP
  654. setup_smp();
  655. #endif
  656. paging_init();
  657. }
  658. static char sys_unknown[] = "Unknown";
  659. static char systype_names[][16] = {
  660. "0",
  661. "ADU", "Cobra", "Ruby", "Flamingo", "Mannequin", "Jensen",
  662. "Pelican", "Morgan", "Sable", "Medulla", "Noname",
  663. "Turbolaser", "Avanti", "Mustang", "Alcor", "Tradewind",
  664. "Mikasa", "EB64", "EB66", "EB64+", "AlphaBook1",
  665. "Rawhide", "K2", "Lynx", "XL", "EB164", "Noritake",
  666. "Cortex", "29", "Miata", "XXM", "Takara", "Yukon",
  667. "Tsunami", "Wildfire", "CUSCO", "Eiger", "Titan", "Marvel"
  668. };
  669. static char unofficial_names[][8] = {"100", "Ruffian"};
  670. static char api_names[][16] = {"200", "Nautilus"};
  671. static char eb164_names[][8] = {"EB164", "PC164", "LX164", "SX164", "RX164"};
  672. static int eb164_indices[] = {0,0,0,1,1,1,1,1,2,2,2,2,3,3,3,3,4};
  673. static char alcor_names[][16] = {"Alcor", "Maverick", "Bret"};
  674. static int alcor_indices[] = {0,0,0,1,1,1,0,0,0,0,0,0,2,2,2,2,2,2};
  675. static char eb64p_names[][16] = {"EB64+", "Cabriolet", "AlphaPCI64"};
  676. static int eb64p_indices[] = {0,0,1,2};
  677. static char eb66_names[][8] = {"EB66", "EB66+"};
  678. static int eb66_indices[] = {0,0,1};
  679. static char marvel_names[][16] = {
  680. "Marvel/EV7"
  681. };
  682. static int marvel_indices[] = { 0 };
  683. static char rawhide_names[][16] = {
  684. "Dodge", "Wrangler", "Durango", "Tincup", "DaVinci"
  685. };
  686. static int rawhide_indices[] = {0,0,0,1,1,2,2,3,3,4,4};
  687. static char titan_names[][16] = {
  688. "DEFAULT", "Privateer", "Falcon", "Granite"
  689. };
  690. static int titan_indices[] = {0,1,2,2,3};
  691. static char tsunami_names[][16] = {
  692. "0", "DP264", "Warhol", "Windjammer", "Monet", "Clipper",
  693. "Goldrush", "Webbrick", "Catamaran", "Brisbane", "Melbourne",
  694. "Flying Clipper", "Shark"
  695. };
  696. static int tsunami_indices[] = {0,1,2,3,4,5,6,7,8,9,10,11,12};
  697. static struct alpha_machine_vector * __init
  698. get_sysvec(unsigned long type, unsigned long variation, unsigned long cpu)
  699. {
  700. static struct alpha_machine_vector *systype_vecs[] __initdata =
  701. {
  702. NULL, /* 0 */
  703. NULL, /* ADU */
  704. NULL, /* Cobra */
  705. NULL, /* Ruby */
  706. NULL, /* Flamingo */
  707. NULL, /* Mannequin */
  708. &jensen_mv,
  709. NULL, /* Pelican */
  710. NULL, /* Morgan */
  711. NULL, /* Sable -- see below. */
  712. NULL, /* Medulla */
  713. &noname_mv,
  714. NULL, /* Turbolaser */
  715. &avanti_mv,
  716. NULL, /* Mustang */
  717. NULL, /* Alcor, Bret, Maverick. HWRPB inaccurate? */
  718. NULL, /* Tradewind */
  719. NULL, /* Mikasa -- see below. */
  720. NULL, /* EB64 */
  721. NULL, /* EB66 -- see variation. */
  722. NULL, /* EB64+ -- see variation. */
  723. &alphabook1_mv,
  724. &rawhide_mv,
  725. NULL, /* K2 */
  726. &lynx_mv, /* Lynx */
  727. &xl_mv,
  728. NULL, /* EB164 -- see variation. */
  729. NULL, /* Noritake -- see below. */
  730. NULL, /* Cortex */
  731. NULL, /* 29 */
  732. &miata_mv,
  733. NULL, /* XXM */
  734. &takara_mv,
  735. NULL, /* Yukon */
  736. NULL, /* Tsunami -- see variation. */
  737. &wildfire_mv, /* Wildfire */
  738. NULL, /* CUSCO */
  739. &eiger_mv, /* Eiger */
  740. NULL, /* Titan */
  741. NULL, /* Marvel */
  742. };
  743. static struct alpha_machine_vector *unofficial_vecs[] __initdata =
  744. {
  745. NULL, /* 100 */
  746. &ruffian_mv,
  747. };
  748. static struct alpha_machine_vector *api_vecs[] __initdata =
  749. {
  750. NULL, /* 200 */
  751. &nautilus_mv,
  752. };
  753. static struct alpha_machine_vector *alcor_vecs[] __initdata =
  754. {
  755. &alcor_mv, &xlt_mv, &xlt_mv
  756. };
  757. static struct alpha_machine_vector *eb164_vecs[] __initdata =
  758. {
  759. &eb164_mv, &pc164_mv, &lx164_mv, &sx164_mv, &rx164_mv
  760. };
  761. static struct alpha_machine_vector *eb64p_vecs[] __initdata =
  762. {
  763. &eb64p_mv,
  764. &cabriolet_mv,
  765. &cabriolet_mv /* AlphaPCI64 */
  766. };
  767. static struct alpha_machine_vector *eb66_vecs[] __initdata =
  768. {
  769. &eb66_mv,
  770. &eb66p_mv
  771. };
  772. static struct alpha_machine_vector *marvel_vecs[] __initdata =
  773. {
  774. &marvel_ev7_mv,
  775. };
  776. static struct alpha_machine_vector *titan_vecs[] __initdata =
  777. {
  778. &titan_mv, /* default */
  779. &privateer_mv, /* privateer */
  780. &titan_mv, /* falcon */
  781. &privateer_mv, /* granite */
  782. };
  783. static struct alpha_machine_vector *tsunami_vecs[] __initdata =
  784. {
  785. NULL,
  786. &dp264_mv, /* dp264 */
  787. &dp264_mv, /* warhol */
  788. &dp264_mv, /* windjammer */
  789. &monet_mv, /* monet */
  790. &clipper_mv, /* clipper */
  791. &dp264_mv, /* goldrush */
  792. &webbrick_mv, /* webbrick */
  793. &dp264_mv, /* catamaran */
  794. NULL, /* brisbane? */
  795. NULL, /* melbourne? */
  796. NULL, /* flying clipper? */
  797. &shark_mv, /* shark */
  798. };
  799. /* ??? Do we need to distinguish between Rawhides? */
  800. struct alpha_machine_vector *vec;
  801. /* Search the system tables first... */
  802. vec = NULL;
  803. if (type < ARRAY_SIZE(systype_vecs)) {
  804. vec = systype_vecs[type];
  805. } else if ((type > ST_API_BIAS) &&
  806. (type - ST_API_BIAS) < ARRAY_SIZE(api_vecs)) {
  807. vec = api_vecs[type - ST_API_BIAS];
  808. } else if ((type > ST_UNOFFICIAL_BIAS) &&
  809. (type - ST_UNOFFICIAL_BIAS) < ARRAY_SIZE(unofficial_vecs)) {
  810. vec = unofficial_vecs[type - ST_UNOFFICIAL_BIAS];
  811. }
  812. /* If we've not found one, try for a variation. */
  813. if (!vec) {
  814. /* Member ID is a bit-field. */
  815. unsigned long member = (variation >> 10) & 0x3f;
  816. cpu &= 0xffffffff; /* make it usable */
  817. switch (type) {
  818. case ST_DEC_ALCOR:
  819. if (member < ARRAY_SIZE(alcor_indices))
  820. vec = alcor_vecs[alcor_indices[member]];
  821. break;
  822. case ST_DEC_EB164:
  823. if (member < ARRAY_SIZE(eb164_indices))
  824. vec = eb164_vecs[eb164_indices[member]];
  825. /* PC164 may show as EB164 variation with EV56 CPU,
  826. but, since no true EB164 had anything but EV5... */
  827. if (vec == &eb164_mv && cpu == EV56_CPU)
  828. vec = &pc164_mv;
  829. break;
  830. case ST_DEC_EB64P:
  831. if (member < ARRAY_SIZE(eb64p_indices))
  832. vec = eb64p_vecs[eb64p_indices[member]];
  833. break;
  834. case ST_DEC_EB66:
  835. if (member < ARRAY_SIZE(eb66_indices))
  836. vec = eb66_vecs[eb66_indices[member]];
  837. break;
  838. case ST_DEC_MARVEL:
  839. if (member < ARRAY_SIZE(marvel_indices))
  840. vec = marvel_vecs[marvel_indices[member]];
  841. break;
  842. case ST_DEC_TITAN:
  843. vec = titan_vecs[0]; /* default */
  844. if (member < ARRAY_SIZE(titan_indices))
  845. vec = titan_vecs[titan_indices[member]];
  846. break;
  847. case ST_DEC_TSUNAMI:
  848. if (member < ARRAY_SIZE(tsunami_indices))
  849. vec = tsunami_vecs[tsunami_indices[member]];
  850. break;
  851. case ST_DEC_1000:
  852. if (cpu == EV5_CPU || cpu == EV56_CPU)
  853. vec = &mikasa_primo_mv;
  854. else
  855. vec = &mikasa_mv;
  856. break;
  857. case ST_DEC_NORITAKE:
  858. if (cpu == EV5_CPU || cpu == EV56_CPU)
  859. vec = &noritake_primo_mv;
  860. else
  861. vec = &noritake_mv;
  862. break;
  863. case ST_DEC_2100_A500:
  864. if (cpu == EV5_CPU || cpu == EV56_CPU)
  865. vec = &sable_gamma_mv;
  866. else
  867. vec = &sable_mv;
  868. break;
  869. }
  870. }
  871. return vec;
  872. }
  873. static struct alpha_machine_vector * __init
  874. get_sysvec_byname(const char *name)
  875. {
  876. static struct alpha_machine_vector *all_vecs[] __initdata =
  877. {
  878. &alcor_mv,
  879. &alphabook1_mv,
  880. &avanti_mv,
  881. &cabriolet_mv,
  882. &clipper_mv,
  883. &dp264_mv,
  884. &eb164_mv,
  885. &eb64p_mv,
  886. &eb66_mv,
  887. &eb66p_mv,
  888. &eiger_mv,
  889. &jensen_mv,
  890. &lx164_mv,
  891. &lynx_mv,
  892. &miata_mv,
  893. &mikasa_mv,
  894. &mikasa_primo_mv,
  895. &monet_mv,
  896. &nautilus_mv,
  897. &noname_mv,
  898. &noritake_mv,
  899. &noritake_primo_mv,
  900. &p2k_mv,
  901. &pc164_mv,
  902. &privateer_mv,
  903. &rawhide_mv,
  904. &ruffian_mv,
  905. &rx164_mv,
  906. &sable_mv,
  907. &sable_gamma_mv,
  908. &shark_mv,
  909. &sx164_mv,
  910. &takara_mv,
  911. &webbrick_mv,
  912. &wildfire_mv,
  913. &xl_mv,
  914. &xlt_mv
  915. };
  916. size_t i;
  917. for (i = 0; i < ARRAY_SIZE(all_vecs); ++i) {
  918. struct alpha_machine_vector *mv = all_vecs[i];
  919. if (strcasecmp(mv->vector_name, name) == 0)
  920. return mv;
  921. }
  922. return NULL;
  923. }
  924. static void
  925. get_sysnames(unsigned long type, unsigned long variation, unsigned long cpu,
  926. char **type_name, char **variation_name)
  927. {
  928. unsigned long member;
  929. /* If not in the tables, make it UNKNOWN,
  930. else set type name to family */
  931. if (type < ARRAY_SIZE(systype_names)) {
  932. *type_name = systype_names[type];
  933. } else if ((type > ST_API_BIAS) &&
  934. (type - ST_API_BIAS) < ARRAY_SIZE(api_names)) {
  935. *type_name = api_names[type - ST_API_BIAS];
  936. } else if ((type > ST_UNOFFICIAL_BIAS) &&
  937. (type - ST_UNOFFICIAL_BIAS) < ARRAY_SIZE(unofficial_names)) {
  938. *type_name = unofficial_names[type - ST_UNOFFICIAL_BIAS];
  939. } else {
  940. *type_name = sys_unknown;
  941. *variation_name = sys_unknown;
  942. return;
  943. }
  944. /* Set variation to "0"; if variation is zero, done. */
  945. *variation_name = systype_names[0];
  946. if (variation == 0) {
  947. return;
  948. }
  949. member = (variation >> 10) & 0x3f; /* member ID is a bit-field */
  950. cpu &= 0xffffffff; /* make it usable */
  951. switch (type) { /* select by family */
  952. default: /* default to variation "0" for now */
  953. break;
  954. case ST_DEC_EB164:
  955. if (member < ARRAY_SIZE(eb164_indices))
  956. *variation_name = eb164_names[eb164_indices[member]];
  957. /* PC164 may show as EB164 variation, but with EV56 CPU,
  958. so, since no true EB164 had anything but EV5... */
  959. if (eb164_indices[member] == 0 && cpu == EV56_CPU)
  960. *variation_name = eb164_names[1]; /* make it PC164 */
  961. break;
  962. case ST_DEC_ALCOR:
  963. if (member < ARRAY_SIZE(alcor_indices))
  964. *variation_name = alcor_names[alcor_indices[member]];
  965. break;
  966. case ST_DEC_EB64P:
  967. if (member < ARRAY_SIZE(eb64p_indices))
  968. *variation_name = eb64p_names[eb64p_indices[member]];
  969. break;
  970. case ST_DEC_EB66:
  971. if (member < ARRAY_SIZE(eb66_indices))
  972. *variation_name = eb66_names[eb66_indices[member]];
  973. break;
  974. case ST_DEC_MARVEL:
  975. if (member < ARRAY_SIZE(marvel_indices))
  976. *variation_name = marvel_names[marvel_indices[member]];
  977. break;
  978. case ST_DEC_RAWHIDE:
  979. if (member < ARRAY_SIZE(rawhide_indices))
  980. *variation_name = rawhide_names[rawhide_indices[member]];
  981. break;
  982. case ST_DEC_TITAN:
  983. *variation_name = titan_names[0]; /* default */
  984. if (member < ARRAY_SIZE(titan_indices))
  985. *variation_name = titan_names[titan_indices[member]];
  986. break;
  987. case ST_DEC_TSUNAMI:
  988. if (member < ARRAY_SIZE(tsunami_indices))
  989. *variation_name = tsunami_names[tsunami_indices[member]];
  990. break;
  991. }
  992. }
  993. /*
  994. * A change was made to the HWRPB via an ECO and the following code
  995. * tracks a part of the ECO. In HWRPB versions less than 5, the ECO
  996. * was not implemented in the console firmware. If it's revision 5 or
  997. * greater we can get the name of the platform as an ASCII string from
  998. * the HWRPB. That's what this function does. It checks the revision
  999. * level and if the string is in the HWRPB it returns the address of
  1000. * the string--a pointer to the name of the platform.
  1001. *
  1002. * Returns:
  1003. * - Pointer to a ASCII string if it's in the HWRPB
  1004. * - Pointer to a blank string if the data is not in the HWRPB.
  1005. */
  1006. static char *
  1007. platform_string(void)
  1008. {
  1009. struct dsr_struct *dsr;
  1010. static char unk_system_string[] = "N/A";
  1011. /* Go to the console for the string pointer.
  1012. * If the rpb_vers is not 5 or greater the rpb
  1013. * is old and does not have this data in it.
  1014. */
  1015. if (hwrpb->revision < 5)
  1016. return (unk_system_string);
  1017. else {
  1018. /* The Dynamic System Recognition struct
  1019. * has the system platform name starting
  1020. * after the character count of the string.
  1021. */
  1022. dsr = ((struct dsr_struct *)
  1023. ((char *)hwrpb + hwrpb->dsr_offset));
  1024. return ((char *)dsr + (dsr->sysname_off +
  1025. sizeof(long)));
  1026. }
  1027. }
  1028. static int
  1029. get_nr_processors(struct percpu_struct *cpubase, unsigned long num)
  1030. {
  1031. struct percpu_struct *cpu;
  1032. unsigned long i;
  1033. int count = 0;
  1034. for (i = 0; i < num; i++) {
  1035. cpu = (struct percpu_struct *)
  1036. ((char *)cpubase + i*hwrpb->processor_size);
  1037. if ((cpu->flags & 0x1cc) == 0x1cc)
  1038. count++;
  1039. }
  1040. return count;
  1041. }
  1042. static void
  1043. show_cache_size (struct seq_file *f, const char *which, int shape)
  1044. {
  1045. if (shape == -1)
  1046. seq_printf (f, "%s\t\t: n/a\n", which);
  1047. else if (shape == 0)
  1048. seq_printf (f, "%s\t\t: unknown\n", which);
  1049. else
  1050. seq_printf (f, "%s\t\t: %dK, %d-way, %db line\n",
  1051. which, shape >> 10, shape & 15,
  1052. 1 << ((shape >> 4) & 15));
  1053. }
  1054. static int
  1055. show_cpuinfo(struct seq_file *f, void *slot)
  1056. {
  1057. extern struct unaligned_stat {
  1058. unsigned long count, va, pc;
  1059. } unaligned[2];
  1060. static char cpu_names[][8] = {
  1061. "EV3", "EV4", "Simulate", "LCA4", "EV5", "EV45", "EV56",
  1062. "EV6", "PCA56", "PCA57", "EV67", "EV68CB", "EV68AL",
  1063. "EV68CX", "EV7", "EV79", "EV69"
  1064. };
  1065. struct percpu_struct *cpu = slot;
  1066. unsigned int cpu_index;
  1067. char *cpu_name;
  1068. char *systype_name;
  1069. char *sysvariation_name;
  1070. int nr_processors;
  1071. unsigned long timer_freq;
  1072. cpu_index = (unsigned) (cpu->type - 1);
  1073. cpu_name = "Unknown";
  1074. if (cpu_index < ARRAY_SIZE(cpu_names))
  1075. cpu_name = cpu_names[cpu_index];
  1076. get_sysnames(hwrpb->sys_type, hwrpb->sys_variation,
  1077. cpu->type, &systype_name, &sysvariation_name);
  1078. nr_processors = get_nr_processors(cpu, hwrpb->nr_processors);
  1079. #if CONFIG_HZ == 1024 || CONFIG_HZ == 1200
  1080. timer_freq = (100UL * hwrpb->intr_freq) / 4096;
  1081. #else
  1082. timer_freq = 100UL * CONFIG_HZ;
  1083. #endif
  1084. seq_printf(f, "cpu\t\t\t: Alpha\n"
  1085. "cpu model\t\t: %s\n"
  1086. "cpu variation\t\t: %ld\n"
  1087. "cpu revision\t\t: %ld\n"
  1088. "cpu serial number\t: %s\n"
  1089. "system type\t\t: %s\n"
  1090. "system variation\t: %s\n"
  1091. "system revision\t\t: %ld\n"
  1092. "system serial number\t: %s\n"
  1093. "cycle frequency [Hz]\t: %lu %s\n"
  1094. "timer frequency [Hz]\t: %lu.%02lu\n"
  1095. "page size [bytes]\t: %ld\n"
  1096. "phys. address bits\t: %ld\n"
  1097. "max. addr. space #\t: %ld\n"
  1098. "BogoMIPS\t\t: %lu.%02lu\n"
  1099. "kernel unaligned acc\t: %ld (pc=%lx,va=%lx)\n"
  1100. "user unaligned acc\t: %ld (pc=%lx,va=%lx)\n"
  1101. "platform string\t\t: %s\n"
  1102. "cpus detected\t\t: %d\n",
  1103. cpu_name, cpu->variation, cpu->revision,
  1104. (char*)cpu->serial_no,
  1105. systype_name, sysvariation_name, hwrpb->sys_revision,
  1106. (char*)hwrpb->ssn,
  1107. est_cycle_freq ? : hwrpb->cycle_freq,
  1108. est_cycle_freq ? "est." : "",
  1109. timer_freq / 100, timer_freq % 100,
  1110. hwrpb->pagesize,
  1111. hwrpb->pa_bits,
  1112. hwrpb->max_asn,
  1113. loops_per_jiffy / (500000/HZ),
  1114. (loops_per_jiffy / (5000/HZ)) % 100,
  1115. unaligned[0].count, unaligned[0].pc, unaligned[0].va,
  1116. unaligned[1].count, unaligned[1].pc, unaligned[1].va,
  1117. platform_string(), nr_processors);
  1118. #ifdef CONFIG_SMP
  1119. seq_printf(f, "cpus active\t\t: %u\n"
  1120. "cpu active mask\t\t: %016lx\n",
  1121. num_online_cpus(), cpumask_bits(cpu_possible_mask)[0]);
  1122. #endif
  1123. show_cache_size (f, "L1 Icache", alpha_l1i_cacheshape);
  1124. show_cache_size (f, "L1 Dcache", alpha_l1d_cacheshape);
  1125. show_cache_size (f, "L2 cache", alpha_l2_cacheshape);
  1126. show_cache_size (f, "L3 cache", alpha_l3_cacheshape);
  1127. return 0;
  1128. }
  1129. static int __init
  1130. read_mem_block(int *addr, int stride, int size)
  1131. {
  1132. long nloads = size / stride, cnt, tmp;
  1133. __asm__ __volatile__(
  1134. " rpcc %0\n"
  1135. "1: ldl %3,0(%2)\n"
  1136. " subq %1,1,%1\n"
  1137. /* Next two XORs introduce an explicit data dependency between
  1138. consecutive loads in the loop, which will give us true load
  1139. latency. */
  1140. " xor %3,%2,%2\n"
  1141. " xor %3,%2,%2\n"
  1142. " addq %2,%4,%2\n"
  1143. " bne %1,1b\n"
  1144. " rpcc %3\n"
  1145. " subl %3,%0,%0\n"
  1146. : "=&r" (cnt), "=&r" (nloads), "=&r" (addr), "=&r" (tmp)
  1147. : "r" (stride), "1" (nloads), "2" (addr));
  1148. return cnt / (size / stride);
  1149. }
  1150. #define CSHAPE(totalsize, linesize, assoc) \
  1151. ((totalsize & ~0xff) | (linesize << 4) | assoc)
  1152. /* ??? EV5 supports up to 64M, but did the systems with more than
  1153. 16M of BCACHE ever exist? */
  1154. #define MAX_BCACHE_SIZE 16*1024*1024
  1155. /* Note that the offchip caches are direct mapped on all Alphas. */
  1156. static int __init
  1157. external_cache_probe(int minsize, int width)
  1158. {
  1159. int cycles, prev_cycles = 1000000;
  1160. int stride = 1 << width;
  1161. long size = minsize, maxsize = MAX_BCACHE_SIZE * 2;
  1162. if (maxsize > (max_low_pfn + 1) << PAGE_SHIFT)
  1163. maxsize = 1 << (ilog2(max_low_pfn + 1) + PAGE_SHIFT);
  1164. /* Get the first block cached. */
  1165. read_mem_block(__va(0), stride, size);
  1166. while (size < maxsize) {
  1167. /* Get an average load latency in cycles. */
  1168. cycles = read_mem_block(__va(0), stride, size);
  1169. if (cycles > prev_cycles * 2) {
  1170. /* Fine, we exceed the cache. */
  1171. printk("%ldK Bcache detected; load hit latency %d "
  1172. "cycles, load miss latency %d cycles\n",
  1173. size >> 11, prev_cycles, cycles);
  1174. return CSHAPE(size >> 1, width, 1);
  1175. }
  1176. /* Try to get the next block cached. */
  1177. read_mem_block(__va(size), stride, size);
  1178. prev_cycles = cycles;
  1179. size <<= 1;
  1180. }
  1181. return -1; /* No BCACHE found. */
  1182. }
  1183. static void __init
  1184. determine_cpu_caches (unsigned int cpu_type)
  1185. {
  1186. int L1I, L1D, L2, L3;
  1187. switch (cpu_type) {
  1188. case EV4_CPU:
  1189. case EV45_CPU:
  1190. {
  1191. if (cpu_type == EV4_CPU)
  1192. L1I = CSHAPE(8*1024, 5, 1);
  1193. else
  1194. L1I = CSHAPE(16*1024, 5, 1);
  1195. L1D = L1I;
  1196. L3 = -1;
  1197. /* BIU_CTL is a write-only Abox register. PALcode has a
  1198. shadow copy, and may be available from some versions
  1199. of the CSERVE PALcall. If we can get it, then
  1200. unsigned long biu_ctl, size;
  1201. size = 128*1024 * (1 << ((biu_ctl >> 28) & 7));
  1202. L2 = CSHAPE (size, 5, 1);
  1203. Unfortunately, we can't rely on that.
  1204. */
  1205. L2 = external_cache_probe(128*1024, 5);
  1206. break;
  1207. }
  1208. case LCA4_CPU:
  1209. {
  1210. unsigned long car, size;
  1211. L1I = L1D = CSHAPE(8*1024, 5, 1);
  1212. L3 = -1;
  1213. car = *(vuip) phys_to_virt (0x120000078UL);
  1214. size = 64*1024 * (1 << ((car >> 5) & 7));
  1215. /* No typo -- 8 byte cacheline size. Whodathunk. */
  1216. L2 = (car & 1 ? CSHAPE (size, 3, 1) : -1);
  1217. break;
  1218. }
  1219. case EV5_CPU:
  1220. case EV56_CPU:
  1221. {
  1222. unsigned long sc_ctl, width;
  1223. L1I = L1D = CSHAPE(8*1024, 5, 1);
  1224. /* Check the line size of the Scache. */
  1225. sc_ctl = *(vulp) phys_to_virt (0xfffff000a8UL);
  1226. width = sc_ctl & 0x1000 ? 6 : 5;
  1227. L2 = CSHAPE (96*1024, width, 3);
  1228. /* BC_CONTROL and BC_CONFIG are write-only IPRs. PALcode
  1229. has a shadow copy, and may be available from some versions
  1230. of the CSERVE PALcall. If we can get it, then
  1231. unsigned long bc_control, bc_config, size;
  1232. size = 1024*1024 * (1 << ((bc_config & 7) - 1));
  1233. L3 = (bc_control & 1 ? CSHAPE (size, width, 1) : -1);
  1234. Unfortunately, we can't rely on that.
  1235. */
  1236. L3 = external_cache_probe(1024*1024, width);
  1237. break;
  1238. }
  1239. case PCA56_CPU:
  1240. case PCA57_CPU:
  1241. {
  1242. if (cpu_type == PCA56_CPU) {
  1243. L1I = CSHAPE(16*1024, 6, 1);
  1244. L1D = CSHAPE(8*1024, 5, 1);
  1245. } else {
  1246. L1I = CSHAPE(32*1024, 6, 2);
  1247. L1D = CSHAPE(16*1024, 5, 1);
  1248. }
  1249. L3 = -1;
  1250. #if 0
  1251. unsigned long cbox_config, size;
  1252. cbox_config = *(vulp) phys_to_virt (0xfffff00008UL);
  1253. size = 512*1024 * (1 << ((cbox_config >> 12) & 3));
  1254. L2 = ((cbox_config >> 31) & 1 ? CSHAPE (size, 6, 1) : -1);
  1255. #else
  1256. L2 = external_cache_probe(512*1024, 6);
  1257. #endif
  1258. break;
  1259. }
  1260. case EV6_CPU:
  1261. case EV67_CPU:
  1262. case EV68CB_CPU:
  1263. case EV68AL_CPU:
  1264. case EV68CX_CPU:
  1265. case EV69_CPU:
  1266. L1I = L1D = CSHAPE(64*1024, 6, 2);
  1267. L2 = external_cache_probe(1024*1024, 6);
  1268. L3 = -1;
  1269. break;
  1270. case EV7_CPU:
  1271. case EV79_CPU:
  1272. L1I = L1D = CSHAPE(64*1024, 6, 2);
  1273. L2 = CSHAPE(7*1024*1024/4, 6, 7);
  1274. L3 = -1;
  1275. break;
  1276. default:
  1277. /* Nothing known about this cpu type. */
  1278. L1I = L1D = L2 = L3 = 0;
  1279. break;
  1280. }
  1281. alpha_l1i_cacheshape = L1I;
  1282. alpha_l1d_cacheshape = L1D;
  1283. alpha_l2_cacheshape = L2;
  1284. alpha_l3_cacheshape = L3;
  1285. }
  1286. /*
  1287. * We show only CPU #0 info.
  1288. */
  1289. static void *
  1290. c_start(struct seq_file *f, loff_t *pos)
  1291. {
  1292. return *pos ? NULL : (char *)hwrpb + hwrpb->processor_offset;
  1293. }
  1294. static void *
  1295. c_next(struct seq_file *f, void *v, loff_t *pos)
  1296. {
  1297. return NULL;
  1298. }
  1299. static void
  1300. c_stop(struct seq_file *f, void *v)
  1301. {
  1302. }
  1303. const struct seq_operations cpuinfo_op = {
  1304. .start = c_start,
  1305. .next = c_next,
  1306. .stop = c_stop,
  1307. .show = show_cpuinfo,
  1308. };
  1309. static int
  1310. alpha_panic_event(struct notifier_block *this, unsigned long event, void *ptr)
  1311. {
  1312. #if 1
  1313. /* FIXME FIXME FIXME */
  1314. /* If we are using SRM and serial console, just hard halt here. */
  1315. if (alpha_using_srm && srmcons_output)
  1316. __halt();
  1317. #endif
  1318. return NOTIFY_DONE;
  1319. }
  1320. static __init int add_pcspkr(void)
  1321. {
  1322. struct platform_device *pd;
  1323. int ret;
  1324. pd = platform_device_alloc("pcspkr", -1);
  1325. if (!pd)
  1326. return -ENOMEM;
  1327. ret = platform_device_add(pd);
  1328. if (ret)
  1329. platform_device_put(pd);
  1330. return ret;
  1331. }
  1332. device_initcall(add_pcspkr);