geninit.b 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. implement Init;
  2. #
  3. # init program for native inferno, generic pc version
  4. #
  5. include "sys.m";
  6. sys: Sys;
  7. FD, Connection, sprint, Dir: import sys;
  8. print, fprint, open, bind, mount, dial, sleep, read, chdir: import sys;
  9. include "draw.m";
  10. draw: Draw;
  11. Context: import draw;
  12. include "keyring.m";
  13. kr: Keyring;
  14. Init: module
  15. {
  16. init: fn();
  17. };
  18. Shell: module
  19. {
  20. init: fn(ctxt: ref Context, argv: list of string);
  21. };
  22. init()
  23. {
  24. sys = load Sys Sys->PATH;
  25. stdin := sys->fildes(0);
  26. kr = load Keyring Keyring->PATH;
  27. sys->print("**\n** Inferno\n** Vita Nuova\n**\n");
  28. sys->print("Setup boot net services ...\n");
  29. #
  30. # Setup what we need to call a server and
  31. # Authenticate
  32. #
  33. sys->print("Bind console ...\n");
  34. bind("#c", "/dev", sys->MAFTER);
  35. setsysname();
  36. print("Standalone mode\n");
  37. #
  38. # default namespace
  39. #
  40. sys->unmount(nil, "/dev");
  41. bind("#p", "/prog", sys->MREPL); # prog device
  42. sys->bind("#d", "/fd", Sys->MREPL);
  43. bind("#c", "/dev", sys->MBEFORE); # console
  44. bind("#m", "/dev", sys->MAFTER); # mouse setup device
  45. bind("#t", "/dev", sys->MAFTER); # serial device
  46. mouse := load Shell "/dis/mouse.dis";
  47. if (mouse != nil) {
  48. print("Setting up mouse\n");
  49. mouse->init(nil, "/dis/mouse.dis" :: nil);
  50. mouse = nil;
  51. }
  52. # create fake nameserver db that can be written to later
  53. ramfile := load Shell "/dis/ramfile.dis";
  54. if (ramfile != nil) {
  55. ramfile->init(nil, "/dis/ramfile.dis" :: "/services/dns/db" :: "" :: nil);
  56. ramfile = nil;
  57. }
  58. print("Console...\n");
  59. shell := load Shell "/dis/sh.dis";
  60. if(shell == nil) {
  61. print("init: load /dis/sh.dis: %r\n");
  62. exit;
  63. }
  64. print("starting shell\n");
  65. shell->init(nil, "/dis/sh.dis" :: nil);
  66. print("shell exited, bye bye\n");
  67. }
  68. #
  69. # Set system name from nvram
  70. #
  71. setsysname()
  72. {
  73. fds := open("/dev/sysname", sys->OWRITE);
  74. if(fds == nil)
  75. return;
  76. buf := array of byte "genericpc";
  77. sys->write(fds, buf, len buf);
  78. }