Commit e6010817 authored by Frode Vatvedt Fjeld's avatar Frode Vatvedt Fjeld

*** empty log message ***

parent 449b61ab
;;;;------------------------------------------------------------------
;;;;
;;;; Copyright (C) 20012000, 2004,
;;;; Department of Computer Science, University of Troms, Norway
;;;;
;;;; Filename: assembly-syntax.lisp
;;;; Description:
;;;; Author: Frode Vatvedt Fjeld <frodef@acm.org>
;;;; Created at: Thu Nov 9 17:34:37 2000
;;;; Distribution: See the accompanying file COPYING.
;;;;
;;;; $Id: assembly-syntax.lisp,v 1.3 2004/01/08 19:50:38 frodef Exp $
;;;;
;;;;------------------------------------------------------------------
(in-package movitz)
(defstruct assembly-macro-environment
(expanders (make-hash-table :test #'eq)))
(defun assembly-macro-expander (symbol amenv)
(gethash symbol (assembly-macro-environment-expanders amenv)))
(defun (setf assembly-macro-expander) (expander symbol amenv)
(setf (gethash symbol (assembly-macro-environment-expanders amenv))
expander))
;;;(defun assembly-macroexpand (prg amenv)
;;; (cond
;;; ((and (consp prg) (symbolp (car prg)))
;;; (let ((expander (assembly-macro-expander (car prg) amenv)))
;;; (if expander
;;; (assembly-macroexpand (funcall expander prg) amenv)
;;; #0=(cons (assembly-macroexpand (car prg) amenv)
;;; (assembly-macroexpand (cdr prg) amenv)))))
;;; ((consp prg) #0#)
;;; (t prg)))
(defun assembly-macroexpand (prg amenv)
(loop for p in prg
as expander = (and (consp p)
(symbolp (car p))
(assembly-macro-expander (car p) amenv))
if expander
append (funcall expander p)
else if (consp p)
append (list (assembly-macroexpand p amenv))
else append (list p)))
;;;(defmacro with-assembly-syntax (&body body)
;;; `(let ((*readtable* (copy-readtable nil)))
;;; (set-dispatch-macro-character
###############################################################
# bochsrc.txt file for DLX Linux disk image.
###############################################################
# how much memory the emulated machine will have
megs: 32
# filename of ROM images
#romimage: file=/usr/local/bochs/1.2.1/BIOS-bochs-latest, address=0xf0000
#vgaromimage: /usr/local/bochs/1.2.1/VGABIOS-elpin-2.40
romimage: file=../../tmp/bochs-cvs/bios/BIOS-bochs-latest, address=0xf0000
vgaromimage: ../../tmp/bochs-cvs/bios/VGABIOS-elpin-2.40
# what disk images will be used
floppya: 1_44=los0-image, status=inserted
#floppya: 1_44=grub, status=inserted
#floppyb: 1_44=floppyb.img, status=inserted
#diskc: file=hd10meg.img, cyl=306, heads=4, spt=17
#newharddrivesupport: enabled=1
# choose the boot disk.
boot: a
# where do we send log messages?
log: bochsout.txt
vga_update_interval: 100000
# disable the mouse, since DLX is text only
mouse: enabled=0
ne2k: ioaddr=0x280, irq=9, mac=00:40:05:18:66:d8, ethmod=fbsd, ethdev=xl0
ne2k: ioaddr=0x300, irq=3, mac=00:40:05:18:66:d9, ethmod=fbsd, ethdev=xl0
# panic: action=report
error: action=report
# debug: action=report
ips: 3000000
# com1: dev=/dev/ptypv
1882
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
2004-01-12 Frode Vatvedt Fjeld <frodef@cs.uit.no>
* Fixed the floppy bootloader so that it will work with BIOSes
whose int13 messes with the GS segment register, like apparently
the Compaq and some others do.
2004-01-09 Frode Vatvedt Fjeld <frodef@cs.uit.no>
* A disclaimer has been added to the file COPYING.
2004-01-06 Frode Vatvedt Fjeld <frodef@cs.uit.no>
* Rewrote the floppy bootloader so that it is now only limited by
the size of floppies rather than the previous about 600 KB
real-mode buffer limit. For some time I've been forced to remove
some features from los0.img in order to squeeze it into 600 KB,
but no more. Bloat is bliss. However, booting with GRUB is always
an option, and probably the best one in the long run, and
certainly for stable installations (should there ever be
such). It's just that the floppy loader is very convenient during
development. [BB-ID: 1680]
2003-12-05 Frode Vatvedt Fjeld <frodef@cs.uit.no>
* Changed the way method dispatches are cached. It used to be
cached with hash-tables, now it's done with alists. The memory
usage and lookup-time should be improved for the common case,
although later on---when we have really big generic-functions---we
might want to be able to revert to hash-tables. [BB-ID: 1328]
2003-12-03 Frode Vatvedt Fjeld <frodef@cs.uit.no>
* :trace and :untrace are now implemented somewhat differently. In
particular, :trace takes one function-name, and a keyword argument
:callers that is a list of function-names, one of which must be
active (on the current call-stack) for trace to occur.
* There was a bug in the reporting of how much memory was being
consumed. That is, room and time would report double the actual
amounts. So now (time (cons 1 2)) should report 8 bytes.
2003-12-02 Frode Vatvedt Fjeld <frodef@cs.uit.no>
* Added some sort of simple multi-line capability for the
repl. It's not true multi-line editing, but at least you're not
limited to one screen-length of input any more.
2003-11-18 Frode Vatvedt Fjeld <frodef@cs.uit.no>
* Improved the style of interfacing hardware registers in the ne2k
driver. So now the driver is quite a bit smaller, and is again
included in the los0 image.
2003-11-10 Frode Vatvedt Fjeld <frodef@cs.uit.no>
* The last feature I added to eval was lambda the macro and the
keyword for the function special operator. So now lambda works as
one expects at the REPL.
* Started this ChangeLog now, as I hope to distribute Movitz more
actively. Not that this changelog will mostly be concerned with
user-visible changes. You can /not/ infer much about the level of
development activity from looking at this.
######################################################################
##
## Copyright (C) 2003,
## Department of Computer Science, University of Tromsoe, Norway.
##
## For distribution policy, see the accompanying file COPYING.
##
## Filename: ideas.txt
## Description:
## Author: Frode Vatvedt Fjeld <frodef@acm.org>
## Created at: Fri Dec 12 19:19:39 2003
##
## $Id: ideas.txt,v 1.1 2003/12/12 18:34:39 frodef Exp $
##
######################################################################
** Method dispatch caching
- Can we make the cache per caller funobj? This should be possible
if we add one cache slot to each (caller) funobj. In many cases
this would allow for a cache-size of 1 or 2, say. And it'd be
possible to determine these cases dynamically.
<!--
Copyright (C) 2003,
Department of Computer Science, University of Tromsoe, Norway.
For distribution policy, see the accompanying file COPYING.
Filename: los0.html
Description:
Author: Frode Vatvedt Fjeld <frodef@acm.org>
Created at: Wed Nov 5 09:55:54 2003
$Id: movitz.html,v 1.19 2004/01/11 17:13:01 frodef Exp $
-->
<html>
<head>
<title>Movitz: A Common Lisp OS development platform</title>
</head>
<body>
<h1>Movitz: A Common Lisp OS development platform</h1>
<tt>$Id: movitz.html,v 1.19 2004/01/11 17:13:01 frodef Exp $</tt>
<h2><a href="files/">Files</a></h2>
<p> The latest <a href="files/los0.img"> los0 kernel image</a> and its
associated <a href="files/ChangeLog">change-log</a> and <a
href="files/COPYING">copying license</a> can be found here. And there
is the <a href="files/movitz.pdf">current technical documentation</a>.
<p> I'd be interested in receiving reports of crashes, and preferably
reproducible ones. I know there are issues with non-US AT
keyboards. If you have keyboard trouble, you might be able to solve it
by saying <tt>:mapkey code</tt> where code is the ASCII value of the
character you want some key to be mapped to.
<p> If the built-in bootloader of los0.img doesn't work (x86
bootloading is a complicated business, apparently), please try loading
it with <a href="http://www.gnu.org/software/grub/">GRUB</a>. I've
prepared a <a href="files/grub-bootloader.img">GRUB bootloader
image</a> that will load a kernel that is appended to it. That is, you
can prepare a bootable floppy something like this:
<p><pre> cat grub-bootloader.img los0.img >/dev/fd0 </pre>
<h2>Introduction</h2>
<p> The Movitz system aspires to be an implementation of ANSI Common
Lisp that targets the ubiquitous x86 PC architecture "on the
metal". That is, running without any operating system or other form of
software environment. Movitz is a development platform for operating
system kernels, embedded, and single-purpose applications. There can
potentially be several completely different operating systems built
using Movitz.
<p> The Movitz system is two things:
<ul>
<li>A minimal run-time environment which is designed for the x86
architecture running in protected mode. It is minimal in the sense
that all Movitz software can depend on them being present. This is
intended to include the full ANSI Common Lisp specification, as well
as the basic functionality required to perform the chores of typical
operating systems. A particular OS system built with Movitz will
presumably extend this minimal run-time with whatever services it
finds appropriate. This part of Movitz is called <em>Muerte</em>.
<li>A cross-compiler that targets the Muerte run-time. This
cross-compiler is written in plain Common Lisp, and is currently being
developed under Allegro CL, GNU Emacs, and FreeBSD, although (with
minor exceptions) nothing in particular binds it to this platform.
</ul>
<h2>The los0 kernel image</h2>
<p> <a href="files/los0.img">The los0 kernel image</a> is the first
instance of a Movitz kernel application, or <em>MoKA</em>, and
contains the current development version of the Muerte. Los0 is a
very minimal MoKA that is used to drive the development of
Muerte. This system provides no run-time services beyond a typical
lisp <a href="http://www.cliki.net/REPL">REPL</a> listener, which may
be used to interactively peek into your system; be it the lisp system
per se or the hardware environment. Try <a
href="http://www.lisp.org/HyperSpec/Body/fun_aproposcm_apropos-list.html"><tt>apropos</tt></a>,
for example. Some REPL top-level commands (mostly debugging-related)
are <tt>:bt :pop :restart :trace :untrace :error :help
:cpu-reset</tt>.
<p> Hardware requirements are approximately: A 386 or better CPU with
slightly more than 2 MB of RAM (the less you have, the sooner you run
out..). The image file can be booted as a floppy image with a PC
emulator like <a href="http://bochs.sf.net">Bochs</a>, VMware, or
VirtualPC, as an actual floppy on a real machine (just <tt>cat</tt>
the image file to the floppy device), or using GRUB or another <a
href="http://www.mcc.ac.uk/Documentation/grub/multiboot.html#SEC_Top">Multiboot</a>
compliant bootloader.
<h2>Status</h2>
<h3>The compiler</h3>
The cross-compiler is fairly complete in terms of the basic mechanisms
required by ANSI CL. However there are most likely bugs to be weeded
out in the more exotic corners of it, like dynamic control-transfers
and the like.
In terms of code quality, in my opinion the compiler produces code
that is reasonable yet far from "great". It is particularly lacking in
the type-inference department. However, the machine-code produced
tends to be shorter than any other x86 Common Lisp compilers I've
compared it to.
<h3>ANSI Common Lisp</h3>
ANSI Common Lisp specifies a quite extensive set of functions, macros,
and types, and these are not all implemented yet. But many are, and in
general my mode of working is to write what to me is "natural" Common
Lisp, and if some operator is not implemented in Muerte, I will
implement it rather than avoid it.
<a href="http://www.cliki.net/CLOS">CLOS</a> and quite a bit of <a
href="http://www.cliki.net/MOP">MOP</a> is supported in the
cross-compiler. At run-time the support is weaker in the sense that
there is for example no facilities for defining new classes or methods
on-the fly. But the introspection is there, and <tt>make-instance</tt>
and other generic functions will do what they are supposed to do.
<h3>Muerte</h3>
Aside from the ANSI Common Lisp library, Muerte consists of functions
to manipulate the CPU and other hardware. There are primitive
accessors like <tt>x86:io-port</tt>, <tt>x86:memref</tt> and
<tt>x86:memref-int</tt>, <tt>x86:eflags</tt>,
<tt>x86:control-register-hi20/lo12</tt>,
<tt>x86:segment-register</tt>, <tt>x86:cpu-id</tt>, and
<tt>x86:read-time-stamp-counter</tt>. CPU introspection is facilitated
with <tt>x86:cpu-signature</tt> and
<tt>x86:find-cpu-features</tt>. All in all, most basic functionality
required to interface any hardware without resorting to inline
assembly is either in place or can easily be added.
<h3>Garbage Collection</h3>
There is no garbage collection scheme implemented yet. Whether a fully
operational GC <em>can</em> be part of Muerte, or whether it requires
extensive support from the particular MoKA run-time, remains to be
seen.
I expect that it turns out that some middle ground must be found: The
basic mechanisms and hooks needed to perform GC will be provided by
Muerte, and the MoKA uses this to provide full GC service (if it will
provide GC at all). In this spirit, I hope to add something like a
simple stop-and-copy GC to los0 soon.
<h2>About OS design in Common Lisp</h2>
Unlike the previous sections, this section is more or less loose
thoughts about what <em>will</em> be rather than describing an
existing system.
<h3>Layering</h3>
I expect Movitz software modules to be categorized broadly as follows:
<dl>
<dt><b>Muerte level</b><dd> This is lower-level functionality that
depend solely on Muerte services. The idea at this level is to provide
a very thin abstraction over the hardware, just enough to make it
convenient to work with in lisp. This means a functional, stateless
interface that makes as few assumptions about how it will be used as
possible. At this level, "functional" (meaning free of side-effects)
applies in a very strong sense, such that e.g. consing must be kept to
an absolute minimum, and when consing can occur must be
predictable. For example, make no assumptions about whether a hardware
device will be used in interrupt-driven or polled mode. The idea is
that modules at this level facilitate exploratory programming, and
also it can be common to every MoKA.
<dt><b>MoKA level</b><dd> This software utilizes the Muerte-level
modules to build 3D desktop AI-enabled operating systems and the like.
</dl>
<address>
<a href="mailto:frodef+los@cs.uit.no">Frode Vatvedt Fjeld</a>
</address>
</body>
</html>
\ No newline at end of file
This diff is collapsed.
;;;;------------------------------------------------------------------
;;;;
;;;; Copyright (C) 20012000, 2002-2004,
;;;; Department of Computer Science, University of Troms, Norway
;;;;
;;;; Filename: eval.lisp
;;;; Description:
;;;; Author: Frode Vatvedt Fjeld <frodef@acm.org>
;;;; Created at: Thu Nov 2 17:45:05 2000
;;;; Distribution: See the accompanying file COPYING.
;;;;
;;;; $Id: eval.lisp,v 1.36 2004/01/13 09:57:44 frodef Exp $
;;;;
;;;;------------------------------------------------------------------
(in-package movitz)
(defun in-package-form-p (form)
(and (consp form)
(string= '#:in-package (car form))))
(defun require-form-p (form)
(and (consp form)
(string= '#:require (car form))))
(defun provide-form-p (form)
(and (consp form)
(string= '#:provide (car form))))
(defun movitz-module-path (require-form)
"Given a require form, return the path of the file that is expected ~
to provide that module."
(let ((module (second require-form)))
(concatenate 'string
"losp/"
(or (third require-form)
(concatenate 'string
(string-downcase (symbol-name module))
".lisp")))))
(defun movitzify-package-name (name)
(let ((name (string name)))
(if (member name '("cl" "common-lisp" "mop")
:test #'string-equal)
(concatenate 'string (string '#:muerte.) name)
name)))
(defmacro with-retries-until-true ((name format-control &rest format-arguments) &body body)
`(do () (nil)
(with-simple-restart (,name ,format-control ,@format-arguments)
(return (progn ,@body)))))
(defun quote-form-p (x)
(and (consp x)
(or (eq 'cl:quote (first x))
(eq 'muerte.cl::quote (first x)))
t))
(defun movitz-constantp (form &optional (environment nil))
(let ((form (translate-program form :cl :muerte.cl)))
(typecase form
(boolean t)
(number t)
(keyword t)
(character t)
(symbol (or (movitz-env-get form 'constantp nil environment)
(typep (movitz-binding form environment) 'constant-object-binding)))
(cons (case (car form)
((muerte.cl::quote) t)
(muerte.cl::not (movitz-constantp (second form))))))))
(defun isconst (x)
(or (integerp x)
(stringp x)
(eq t x)
(eq nil x)
(quote-form-p x)))
(defun eval-form (&rest args)
(apply 'movitz-eval args))
(defun movitz-eval (form &optional env top-level-p)
"3.1.2.1 Form Evaluation"
(let ((form (translate-program form :cl :muerte.cl)))
(typecase form
(symbol (eval-symbol form env top-level-p))
(cons (eval-cons form env top-level-p))
(t (eval-self-evaluating form env top-level-p)))))
(defun eval-form-or-error (form env error-value)
(handler-case (eval-form form env)
(error () error-value)))
(defun eval-symbol (form env top-level-p)
"3.1.2.1.1 Symbols as Forms"
(declare (ignore top-level-p))
(cond
((typep (movitz-binding form env) 'constant-object-binding)
(movitz-print (constant-object (movitz-binding form env))))
((movitz-constantp form env)
(symbol-value form))
;;; ((movitz-lexical-binding form env)
;;; (eval-lexical-variable form env top-level-p))
(t (error "Don't know how to eval symbol-form ~S" form))))
(defun eval-self-evaluating (form env top-level-p)
"3.1.2.1.3 Self-Evaluating Objects"
(declare (ignore env top-level-p))
form)
(defun eval-cons (form env top-level-p)
"3.1.2.1.2 Conses as Forms"
(let ((operator (car form)))
(declare (ignore operator))
(cond
((movitz-constantp form env)
(eval-constant-compound form env top-level-p))
;;; ((lambda-form-p form)
;;; (eval-lambda-form form env top-level-p))
;;; ((symbolp operator)
;;; (cond
;;; ((movitz-special-operator-p operator)
;;; (eval-special-operator form env top-level-p))
;;; ((movitz-macro-function operator env)
;;; (eval-macro-form form env top-level-p))
;;; (t (eval-apply-symbol form env top-level-p))))
(t (case (car form)
(muerte.cl::function
(if (symbolp (second form))
(movitz-env-symbol-function (second form) env)
(error "Don't know how to eval function form ~A." form)))
(t (error "Don't know how to eval compound form ~A" form)))))))
(defun eval-constant-compound (form env top-level-p)
(case (car form)
((cl:quote muerte.cl::quote)
(eval-self-evaluating (second form) env top-level-p))
(muerte.cl::not
(not (eval-form (second form) env nil)))
(t (error "Don't know how to compile constant compound form ~A" form))))
default 0
timeout 5
title Movitz/Los0
kernel 250+2630
title Harddisk
root (hd0,0)
makeactive
chainloader +1
This diff is collapsed.
(in-package :user)
;; (load "../binary-types/binary-types")
(compile-file #p"../binary-types/binary-types" :load-after-compile t)
(let ((*default-pathname-defaults* #+mswindows #p"c:\\src\\read-elf32\\"
#+unix #p"~/src/ia-x86/"))
(load "system.lisp")
(compile-system :ia-x86)
(load-system :ia-x86)
(load-system :ia-x86-instr :interpreted t))
(ia-x86:init-instruction-tables)
(let ((*default-pathname-defaults* #+mswindows #p"c:\\src\\read-elf32\\"
#+unix #p"~/src/read-elf32/"))
(load "Defsystem-allegro.lisp")
(load-system :elf32))
(compile-file #p"../infunix/procfs" :load-after-compile t)
(load "packages.lisp")
(load "movitz.lisp")
(compile-system :movitz)
(load-system :movitz)
#+allegro
(progn
(setf excl:*tenured-bytes-limit* #x2000000)
(setf (system::gsgc-parameter :generation-spread) 12)
(sys:resize-areas :new (* 16 1024 1024)))
\ No newline at end of file
File added
;;;;------------------------------------------------------------------
;;;;
;;;; Copyright (C) 20012000, 2004,
;;;; Department of Computer Science, University of Troms, Norway
;;;;
;;;; Filename: common-lisp.lisp
;;;; Description:
;;;; Author: Frode Vatvedt Fjeld <frodef@acm.org>
;;;; Created at: Tue Dec 5 18:33:01 2000
;;;; Distribution: See the accompanying file COPYING.
;;;;
;;;; $Id: common-lisp.lisp,v 1.4 2004/01/07 19:24:13 frodef Exp $
;;;;
;;;;------------------------------------------------------------------
(require :muerte/common-lisp)
(provide :common-lisp)
;;;;------------------------------------------------------------------
;;;;
;;;; Copyright (C) 2001-2002,
;;;; Department of Computer Science, University of Troms, Norway.
;;;;
;;;; For distribution policy, see the accompanying file COPYING.
;;;;
;;;; Filename: bcd.lisp
;;;; Description:
;;;; Author: Frode Vatvedt Fjeld <frodef@acm.org>
;;;; Created at: Mon Sep 30 14:03:57 2002
;;;;
;;;; $Id: bcd.lisp,v 1.2 2004/01/08 19:12:22 frodef Exp $
;;;;
;;;;------------------------------------------------------------------
(provide :lib/bcd)
(defpackage muerte.lib
(:export bcd-to-integer
integer-to-bcd))
(in-package muerte.lib)
(defun bcd-to-integer (bcd)
(loop for factor = 1 then (* factor 10)
while (plusp bcd)
sum (* factor (ldb (byte 4 0) bcd))
do (setf bcd (ash bcd -4))))
(defun integer-to-bcd (integer)
(loop for factor = 1 then (* factor 16)
while (plusp integer)
sum (* factor (rem integer 10))
do (setf integer (truncate integer 10))))
;;;;------------------------------------------------------------------
;;;;
;;;; Copyright (C) 2001, 2003-2004,
;;;; Department of Computer Science, University of Troms, Norway.
;;;;
;;;; For distribution policy, see the accompanying file COPYING.
;;;;
;;;; Filename: console.lisp
;;;; Description:
;;;; Author: Frode Vatvedt Fjeld <frodef@acm.org>
;;;; Created at: Thu Aug 14 18:14:16 2003
;;;;
;;;; $Id: console.lisp,v 1.11 2004/01/13 09:57:44 frodef Exp $
;;;;
;;;;------------------------------------------------------------------
(provide :lib/console)
(defpackage muerte.lib
(:use muerte)
(:export console
console-width
console-height
cursor-x
cursor-y
console-char
scroll-down
put-string
clear-line
clear-console
local-echo-p
with-saved-excursion))
(in-package muerte.lib)
(defmacro with-saved-excursion ((stream) &body body)
(let ((stream-var (gensym))
(x-var (gensym))
(y-var (gensym))
(scroll-var (gensym)))
`(let ((,stream-var ,stream))
(let ((,x-var (cursor-x ,stream-var))
(,y-var (cursor-y ,stream-var))
(,scroll-var *scroll-offset*))
(multiple-value-prog1 (progn ,@body)
(setf (cursor-x ,stream-var) ,x-var
(cursor-y ,stream-var) (- ,y-var (- *scroll-offset* ,scroll-var))))))))
(defgeneric cursor-x (console)
(:no-clos-fallback console-no-clos))
(defgeneric (setf cursor-x) (x console)
(:no-clos-fallback console-no-clos))
(defgeneric cursor-y (console)
(:no-clos-fallback console-no-clos))
(defgeneric (setf cursor-y) (y console)
(:no-clos-fallback console-no-clos))
(defgeneric console-width (console)
(:no-clos-fallback console-no-clos))
(defgeneric console-height (console)
(:no-clos-fallback console-no-clos))
(defmethod cursor-x ((console function))
(funcall console 'cursor-x))
(defmethod (setf cursor-x) (x (console function))
(funcall console '(setf cursor-x) x))
(defmethod cursor-y ((console function))
(funcall console 'cursor-y))
(defmethod (setf cursor-y) (y (console function))
(funcall console '(setf cursor-y) y))
(defmethod console-height (console)
(funcall console 'console-height))
(defmethod console-width (console)
(funcall console 'console-width))
(defgeneric clear-line (console x y)
(:no-clos-fallback console-no-clos))