load-vm.scm 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. ; -*- Mode: Scheme; Syntax: Scheme; Package: Scheme; -*-
  2. ; Part of Scheme 48 1.9. See file COPYING for notices and license.
  3. ; Authors: Richard Kelsey, Jonathan Rees, Mike Sperber
  4. ; To load the VM into Scheme 48:
  5. ; ,config ,load ../platform-interfaces.scm
  6. ; then
  7. ; ,config ,load ps-platform-32-packages.scm
  8. ; - or -
  9. ; ,config ,load ps-platform-64-packages.scm
  10. ; (ignoring the warning) and then:
  11. ; ,exec ,load load-vm.scm
  12. ; (ignoring "name from opened structure redefined" warnings for the config package)
  13. ; Then, for example,
  14. ; (start-vm "=scheme48/../build/initial.image" 2000000 20000 '#())
  15. ; in the user package will start up the VM with the initial image.
  16. ; Be patient. It will take a while.
  17. ;
  18. ; You will need to have a large heap to start with. Using a BIBOP
  19. ; build with -h 0 works best.
  20. ;
  21. ; To send input to the VM, do the following:
  22. ;
  23. ; Breakpoint: Waiting
  24. ; 1> ,in interpreter (set! s48-*pending-events?* #t)
  25. ; 1> ,proceed
  26. ; (+ 2 3) ; this will be read by the loaded VM
  27. ; Call to (schedule-interrupt 200) ; output noise
  28. ; Call to (schedule-interrupt 200)
  29. ; Call to (schedule-interrupt 200)
  30. ; 5 ; the answer
  31. ; > Call to (schedule-interrupt 200) ; prompt by the loaded S48
  32. ;
  33. ; Breakpoint: Waiting
  34. ; 1> ; prompt by the base S48
  35. ;
  36. ; There can't be a pause between the `,proceed' and the input for
  37. ; the loaded VM. This is easy to accomplish running under Emacs.
  38. ; If there is a pause you will hit the breakpoint again and the
  39. ; `(+ 2 3)' or whatever will be read by the base system.
  40. ;
  41. ; It is easier to debug changes to the VM using images smaller than
  42. ; the usual build/initial.image and scheme48.image. What I usually
  43. ; do is modify scheme/debug/tiny.scm so that it runs the code I want
  44. ; to test and then build scheme/debug/tiny.image. The version that
  45. ; comes with the system prints `Hello' and the first command argument,
  46. ; if any, then reads a line from standard input and prints it to
  47. ; standard output. The image file is less than 12k bytes in size so
  48. ; it starts up much faster than the larger images. Here is a transcript:
  49. ;
  50. ; % make scheme/debug/tiny.image
  51. ; % ./scheme48vm -i scheme/debug/tiny.image -a the-argument
  52. ; Correcting byte order of resumed image.
  53. ; Hello the-argument
  54. ; now I type a line to be echoed
  55. ; now I type a line to be echoed
  56. ; %
  57. ;
  58. ; When modifying scheme/debug/tiny.scm you have to keep in mind that
  59. ; you can only use the basic system: only the standard special forms
  60. ; (no LET, for example) and only the primitives implemented by the
  61. ; VM (no MAP, etc.).
  62. (config)
  63. (load "../prescheme/interface.scm")
  64. (load "../prescheme/package-defs.scm")
  65. (load "interfaces.scm")
  66. (load "shared-interfaces.scm")
  67. (load "s48-package-defs.scm")
  68. (load "package-defs.scm")
  69. (load "twospace-gc-package-defs.scm")
  70. (load-package 'destructuring) ; used in FOR-SYNTAX clause
  71. (load-package 'bigbit)
  72. (load-package 'vm)
  73. (user)
  74. (open 'ps-memory)
  75. (open 'vm)
  76. (open 'heap-init)
  77. (open 'read-image)
  78. (open 'memory-debug)
  79. (run '
  80. (define (start-vm image-file heap-size stack-size start-args)
  81. (reinitialize-memory)
  82. (s48-read-image image-file heap-size)
  83. (s48-initialize-vm (allocate-memory stack-size)
  84. (quotient stack-size 4))
  85. (s48-call-startup-procedure start-args
  86. (vector-length start-args)))
  87. )