compat.c 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. /*
  2. * linux/arch/arm/kernel/compat.c
  3. *
  4. * Copyright (C) 2001 Russell King
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. * We keep the old params compatibility cruft in one place (here)
  11. * so we don't end up with lots of mess around other places.
  12. *
  13. * NOTE:
  14. * The old struct param_struct is deprecated, but it will be kept in
  15. * the kernel for 5 years from now (2001). This will allow boot loaders
  16. * to convert to the new struct tag way.
  17. */
  18. #include <linux/config.h>
  19. #include <linux/types.h>
  20. #include <linux/kernel.h>
  21. #include <linux/string.h>
  22. #include <linux/init.h>
  23. #include <asm/setup.h>
  24. #include <asm/mach-types.h>
  25. #include <asm/page.h>
  26. #include <asm/mach/arch.h>
  27. #include "compat.h"
  28. /*
  29. * Usage:
  30. * - do not go blindly adding fields, add them at the end
  31. * - when adding fields, don't rely on the address until
  32. * a patch from me has been released
  33. * - unused fields should be zero (for future expansion)
  34. * - this structure is relatively short-lived - only
  35. * guaranteed to contain useful data in setup_arch()
  36. *
  37. * This is the old deprecated way to pass parameters to the kernel
  38. */
  39. struct param_struct {
  40. union {
  41. struct {
  42. unsigned long page_size; /* 0 */
  43. unsigned long nr_pages; /* 4 */
  44. unsigned long ramdisk_size; /* 8 */
  45. unsigned long flags; /* 12 */
  46. #define FLAG_READONLY 1
  47. #define FLAG_RDLOAD 4
  48. #define FLAG_RDPROMPT 8
  49. unsigned long rootdev; /* 16 */
  50. unsigned long video_num_cols; /* 20 */
  51. unsigned long video_num_rows; /* 24 */
  52. unsigned long video_x; /* 28 */
  53. unsigned long video_y; /* 32 */
  54. unsigned long memc_control_reg; /* 36 */
  55. unsigned char sounddefault; /* 40 */
  56. unsigned char adfsdrives; /* 41 */
  57. unsigned char bytes_per_char_h; /* 42 */
  58. unsigned char bytes_per_char_v; /* 43 */
  59. unsigned long pages_in_bank[4]; /* 44 */
  60. unsigned long pages_in_vram; /* 60 */
  61. unsigned long initrd_start; /* 64 */
  62. unsigned long initrd_size; /* 68 */
  63. unsigned long rd_start; /* 72 */
  64. unsigned long system_rev; /* 76 */
  65. unsigned long system_serial_low; /* 80 */
  66. unsigned long system_serial_high; /* 84 */
  67. unsigned long mem_fclk_21285; /* 88 */
  68. } s;
  69. char unused[256];
  70. } u1;
  71. union {
  72. char paths[8][128];
  73. struct {
  74. unsigned long magic;
  75. char n[1024 - sizeof(unsigned long)];
  76. } s;
  77. } u2;
  78. char commandline[COMMAND_LINE_SIZE];
  79. };
  80. static struct tag * __init memtag(struct tag *tag, unsigned long start, unsigned long size)
  81. {
  82. tag = tag_next(tag);
  83. tag->hdr.tag = ATAG_MEM;
  84. tag->hdr.size = tag_size(tag_mem32);
  85. tag->u.mem.size = size;
  86. tag->u.mem.start = start;
  87. return tag;
  88. }
  89. static void __init build_tag_list(struct param_struct *params, void *taglist)
  90. {
  91. struct tag *tag = taglist;
  92. if (params->u1.s.page_size != PAGE_SIZE) {
  93. printk(KERN_WARNING "Warning: bad configuration page, "
  94. "trying to continue\n");
  95. return;
  96. }
  97. printk(KERN_DEBUG "Converting old-style param struct to taglist\n");
  98. #ifdef CONFIG_ARCH_NETWINDER
  99. if (params->u1.s.nr_pages != 0x02000 &&
  100. params->u1.s.nr_pages != 0x04000 &&
  101. params->u1.s.nr_pages != 0x08000 &&
  102. params->u1.s.nr_pages != 0x10000) {
  103. printk(KERN_WARNING "Warning: bad NeTTrom parameters "
  104. "detected, using defaults\n");
  105. params->u1.s.nr_pages = 0x1000; /* 16MB */
  106. params->u1.s.ramdisk_size = 0;
  107. params->u1.s.flags = FLAG_READONLY;
  108. params->u1.s.initrd_start = 0;
  109. params->u1.s.initrd_size = 0;
  110. params->u1.s.rd_start = 0;
  111. }
  112. #endif
  113. tag->hdr.tag = ATAG_CORE;
  114. tag->hdr.size = tag_size(tag_core);
  115. tag->u.core.flags = params->u1.s.flags & FLAG_READONLY;
  116. tag->u.core.pagesize = params->u1.s.page_size;
  117. tag->u.core.rootdev = params->u1.s.rootdev;
  118. tag = tag_next(tag);
  119. tag->hdr.tag = ATAG_RAMDISK;
  120. tag->hdr.size = tag_size(tag_ramdisk);
  121. tag->u.ramdisk.flags = (params->u1.s.flags & FLAG_RDLOAD ? 1 : 0) |
  122. (params->u1.s.flags & FLAG_RDPROMPT ? 2 : 0);
  123. tag->u.ramdisk.size = params->u1.s.ramdisk_size;
  124. tag->u.ramdisk.start = params->u1.s.rd_start;
  125. tag = tag_next(tag);
  126. tag->hdr.tag = ATAG_INITRD;
  127. tag->hdr.size = tag_size(tag_initrd);
  128. tag->u.initrd.start = params->u1.s.initrd_start;
  129. tag->u.initrd.size = params->u1.s.initrd_size;
  130. tag = tag_next(tag);
  131. tag->hdr.tag = ATAG_SERIAL;
  132. tag->hdr.size = tag_size(tag_serialnr);
  133. tag->u.serialnr.low = params->u1.s.system_serial_low;
  134. tag->u.serialnr.high = params->u1.s.system_serial_high;
  135. tag = tag_next(tag);
  136. tag->hdr.tag = ATAG_REVISION;
  137. tag->hdr.size = tag_size(tag_revision);
  138. tag->u.revision.rev = params->u1.s.system_rev;
  139. #ifdef CONFIG_ARCH_ACORN
  140. if (machine_is_riscpc()) {
  141. int i;
  142. for (i = 0; i < 4; i++)
  143. tag = memtag(tag, PHYS_OFFSET + (i << 26),
  144. params->u1.s.pages_in_bank[i] * PAGE_SIZE);
  145. } else
  146. #endif
  147. tag = memtag(tag, PHYS_OFFSET, params->u1.s.nr_pages * PAGE_SIZE);
  148. #ifdef CONFIG_FOOTBRIDGE
  149. if (params->u1.s.mem_fclk_21285) {
  150. tag = tag_next(tag);
  151. tag->hdr.tag = ATAG_MEMCLK;
  152. tag->hdr.size = tag_size(tag_memclk);
  153. tag->u.memclk.fmemclk = params->u1.s.mem_fclk_21285;
  154. }
  155. #endif
  156. #ifdef CONFIG_ARCH_EBSA285
  157. if (machine_is_ebsa285()) {
  158. tag = tag_next(tag);
  159. tag->hdr.tag = ATAG_VIDEOTEXT;
  160. tag->hdr.size = tag_size(tag_videotext);
  161. tag->u.videotext.x = params->u1.s.video_x;
  162. tag->u.videotext.y = params->u1.s.video_y;
  163. tag->u.videotext.video_page = 0;
  164. tag->u.videotext.video_mode = 0;
  165. tag->u.videotext.video_cols = params->u1.s.video_num_cols;
  166. tag->u.videotext.video_ega_bx = 0;
  167. tag->u.videotext.video_lines = params->u1.s.video_num_rows;
  168. tag->u.videotext.video_isvga = 1;
  169. tag->u.videotext.video_points = 8;
  170. }
  171. #endif
  172. #ifdef CONFIG_ARCH_ACORN
  173. tag = tag_next(tag);
  174. tag->hdr.tag = ATAG_ACORN;
  175. tag->hdr.size = tag_size(tag_acorn);
  176. tag->u.acorn.memc_control_reg = params->u1.s.memc_control_reg;
  177. tag->u.acorn.vram_pages = params->u1.s.pages_in_vram;
  178. tag->u.acorn.sounddefault = params->u1.s.sounddefault;
  179. tag->u.acorn.adfsdrives = params->u1.s.adfsdrives;
  180. #endif
  181. tag = tag_next(tag);
  182. tag->hdr.tag = ATAG_CMDLINE;
  183. tag->hdr.size = (strlen(params->commandline) + 3 +
  184. sizeof(struct tag_header)) >> 2;
  185. strcpy(tag->u.cmdline.cmdline, params->commandline);
  186. tag = tag_next(tag);
  187. tag->hdr.tag = ATAG_NONE;
  188. tag->hdr.size = 0;
  189. memmove(params, taglist, ((int)tag) - ((int)taglist) +
  190. sizeof(struct tag_header));
  191. }
  192. void __init convert_to_tag_list(struct tag *tags)
  193. {
  194. struct param_struct *params = (struct param_struct *)tags;
  195. build_tag_list(params, &params->u2);
  196. }
  197. void __init squash_mem_tags(struct tag *tag)
  198. {
  199. for (; tag->hdr.size; tag = tag_next(tag))
  200. if (tag->hdr.tag == ATAG_MEM)
  201. tag->hdr.tag = ATAG_NONE;
  202. }