setup.c 39 KB

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