load-vm.scm 3.2 KB

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