9fsfs64.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. #include "all.h"
  2. #include "mem.h"
  3. #include "io.h"
  4. #include "ureg.h"
  5. #include "../pc/dosfs.h"
  6. void apcinit(void);
  7. int sdinit(void);
  8. /*
  9. * setting this to zero permits the use of discs of different sizes, but
  10. * can make jukeinit() quite slow while the robotics work through each disc
  11. * twice (once per side).
  12. */
  13. int FIXEDSIZE = 1;
  14. #ifndef DATE
  15. #define DATE 1094098624L
  16. #endif
  17. Timet mktime = DATE; /* set by mkfile */
  18. Startsb startsb[] =
  19. {
  20. "main", 2, /* */
  21. /* "main", 810988, /* discontinuity before sb @ 696262 */
  22. 0
  23. };
  24. Dos dos;
  25. static struct
  26. {
  27. char *name;
  28. Off (*read)(int, void*, long);
  29. Devsize (*seek)(int, Devsize);
  30. Off (*write)(int, void*, long);
  31. int (*part)(int, char*);
  32. } nvrdevs[] = {
  33. { "fd", floppyread, floppyseek, floppywrite, 0, },
  34. { "hd", ataread, ataseek, atawrite, setatapart, },
  35. { "md", mvsataread, mvsataseek, mvsatawrite, setmv50part, },
  36. /* { "sd", scsiread, scsiseek, scsiwrite, setscsipart, }, */
  37. { 0, },
  38. };
  39. void
  40. otherinit(void)
  41. {
  42. int dev, i, nfd, nhd, s;
  43. char *p, *q, buf[sizeof(nvrfile)+8];
  44. kbdinit();
  45. printcpufreq();
  46. etherinit();
  47. scsiinit();
  48. apcinit();
  49. s = spllo();
  50. sdinit();
  51. nhd = atainit(); /* harmless to call again */
  52. mvsatainit(); /* harmless to call again */
  53. nfd = floppyinit();
  54. dev = 0;
  55. if(p = getconf("nvr")){
  56. strncpy(buf, p, sizeof(buf)-2);
  57. buf[sizeof(buf)-1] = 0;
  58. p = strchr(buf, '!');
  59. q = strrchr(buf, '!');
  60. if(p == 0 || q == 0 || strchr(p+1, '!') != q)
  61. panic("malformed nvrfile: %s\n", buf);
  62. *p++ = 0;
  63. *q++ = 0;
  64. dev = strtoul(p, 0, 0);
  65. strcpy(nvrfile, q);
  66. p = buf;
  67. } else
  68. if(p = getconf("bootfile")){
  69. strncpy(buf, p, sizeof(buf)-2);
  70. buf[sizeof(buf)-1] = 0;
  71. p = strchr(buf, '!');
  72. q = strrchr(buf, '!');
  73. if(p == 0 || q == 0 || strchr(p+1, '!') != q)
  74. panic("malformed bootfile: %s\n", buf);
  75. *p++ = 0;
  76. *q = 0;
  77. dev = strtoul(p, 0, 0);
  78. p = buf;
  79. } else
  80. if(nfd)
  81. p = "fd";
  82. else
  83. if(nhd)
  84. p = "hd";
  85. else
  86. p = "sd";
  87. for(i = 0; nvrdevs[i].name; i++){
  88. if(strcmp(p, nvrdevs[i].name) == 0){
  89. dos.dev = dev;
  90. if (nvrdevs[i].part &&
  91. (*nvrdevs[i].part)(dos.dev, "disk") == 0)
  92. break;
  93. dos.read = nvrdevs[i].read;
  94. dos.seek = nvrdevs[i].seek;
  95. dos.write = nvrdevs[i].write;
  96. break;
  97. }
  98. }
  99. if(dos.read == 0)
  100. panic("no device (%s) for nvram\n", p);
  101. if(dosinit(&dos) < 0)
  102. panic("can't init dos dosfs on %s\n", p);
  103. splx(s);
  104. }
  105. static int
  106. isdawn(void *)
  107. {
  108. return predawn == 0;
  109. }
  110. void
  111. touser(void)
  112. {
  113. int i;
  114. settime(rtctime());
  115. boottime = time();
  116. /* wait for predawn to change to zero to avoid confusing print */
  117. sleep(&dawnrend, isdawn, 0);
  118. print("sysinit\n");
  119. sysinit();
  120. userinit(floppyproc, 0, "floppyproc");
  121. /*
  122. * Ethernet i/o processes
  123. */
  124. etherstart();
  125. /*
  126. * read ahead processes
  127. */
  128. userinit(rahead, 0, "rah");
  129. /*
  130. * server processes
  131. */
  132. for(i=0; i<conf.nserve; i++)
  133. userinit(serve, 0, "srv");
  134. /*
  135. * worm "dump" copy process
  136. */
  137. userinit(wormcopy, 0, "wcp");
  138. /*
  139. * processes to read the console
  140. */
  141. consserve();
  142. /*
  143. * "sync" copy process
  144. * this doesn't return.
  145. */
  146. u->text = "scp";
  147. synccopy();
  148. }
  149. void
  150. localconfinit(void)
  151. {
  152. /* conf.nfile = 60000; */ /* from emelie */
  153. conf.nodump = 0;
  154. conf.dumpreread = 1;
  155. conf.firstsb = 0; /* time- & jukebox-dependent optimisation */
  156. conf.recovsb = 0; /* 971531 is 24 june 2003, before w3 died */
  157. conf.ripoff = 1;
  158. conf.nlgmsg = 1100; /* @8576 bytes, for packets */
  159. conf.nsmmsg = 500; /* @128 bytes */
  160. conf.minuteswest = 8*60;
  161. conf.dsttime = 1;
  162. }
  163. int (*fsprotocol[])(Msgbuf*) = {
  164. /* 64-bit file servers can't serve 9P1 correctly: NAMELEN is too big */
  165. serve9p2,
  166. nil,
  167. };