setup.c 38 KB

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