compat.c 5.2 KB

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