setup.c 38 KB

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