9net32.16kfs.c 3.1 KB

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