setup.c 38 KB

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