9pcfs.c 2.9 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 568011600L+4*3600
  14. #endif
  15. ulong mktime = DATE; /* set by mkfile */
  16. Startsb startsb[] =
  17. {
  18. "main", 2,
  19. 0
  20. };
  21. Dos dos;
  22. static
  23. struct
  24. {
  25. char *name;
  26. long (*read)(int, void*, long);
  27. vlong (*seek)(int, vlong);
  28. long (*write)(int, void*, long);
  29. int (*part)(int, char*);
  30. } nvrdevs[] =
  31. {
  32. { "fd", floppyread, floppyseek, floppywrite, 0, },
  33. { "hd", ataread, ataseek, atawrite, setatapart, },
  34. /*
  35. { "sd", scsiread, scsiseek, scsiwrite, setscsipart, },
  36. */
  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. s = spllo();
  49. nhd = atainit();
  50. nfd = floppyinit();
  51. dev = 0;
  52. if(p = getconf("nvr")){
  53. strncpy(buf, p, sizeof(buf)-2);
  54. buf[sizeof(buf)-1] = 0;
  55. p = strchr(buf, '!');
  56. q = strrchr(buf, '!');
  57. if(p == 0 || q == 0 || strchr(p+1, '!') != q)
  58. panic("malformed nvrfile: %s\n", buf);
  59. *p++ = 0;
  60. *q++ = 0;
  61. dev = strtoul(p, 0, 0);
  62. strcpy(nvrfile, q);
  63. p = buf;
  64. } else
  65. if(p = getconf("bootfile")){
  66. strncpy(buf, p, sizeof(buf)-2);
  67. buf[sizeof(buf)-1] = 0;
  68. p = strchr(buf, '!');
  69. q = strrchr(buf, '!');
  70. if(p == 0 || q == 0 || strchr(p+1, '!') != q)
  71. panic("malformed bootfile: %s\n", buf);
  72. *p++ = 0;
  73. *q = 0;
  74. dev = strtoul(p, 0, 0);
  75. p = buf;
  76. } else
  77. if(nfd)
  78. p = "fd";
  79. else
  80. if(nhd)
  81. p = "hd";
  82. else
  83. p = "sd";
  84. for(i = 0; nvrdevs[i].name; i++){
  85. if(strcmp(p, nvrdevs[i].name) == 0){
  86. dos.dev = dev;
  87. if(nvrdevs[i].part && (*nvrdevs[i].part)(dos.dev, "disk") == 0)
  88. break;
  89. dos.read = nvrdevs[i].read;
  90. dos.seek = nvrdevs[i].seek;
  91. dos.write = nvrdevs[i].write;
  92. break;
  93. }
  94. }
  95. if(dos.read == 0)
  96. panic("no device for nvram\n");
  97. if(dosinit(&dos) < 0)
  98. panic("can't init dos dosfs on %s\n", p);
  99. splx(s);
  100. }
  101. void
  102. touser(void)
  103. {
  104. int i;
  105. settime(rtctime());
  106. boottime = time();
  107. print("sysinit\n");
  108. sysinit();
  109. userinit(floppyproc, 0, "floppyproc");
  110. /*
  111. * Ethernet i/o processes
  112. */
  113. etherstart();
  114. /*
  115. * read ahead processes
  116. */
  117. userinit(rahead, 0, "rah");
  118. /*
  119. * server processes
  120. */
  121. for(i=0; i<conf.nserve; i++)
  122. userinit(serve, 0, "srv");
  123. /*
  124. * worm "dump" copy process
  125. */
  126. userinit(wormcopy, 0, "wcp");
  127. /*
  128. * processes to read the console
  129. */
  130. consserve();
  131. /*
  132. * "sync" copy process
  133. * this doesn't return.
  134. */
  135. u->text = "scp";
  136. synccopy();
  137. }
  138. void
  139. localconfinit(void)
  140. {
  141. conf.nfile = 40000;
  142. conf.nodump = 0;
  143. conf.firstsb = 13219302;
  144. conf.recovsb = 0;
  145. conf.ripoff = 1;
  146. conf.nlgmsg = 100;
  147. conf.nsmmsg = 500;
  148. conf.minuteswest = 5*60;
  149. conf.dsttime = 1;
  150. }
  151. int (*fsprotocol[])(Msgbuf*) = {
  152. serve9p1,
  153. serve9p2,
  154. nil,
  155. };