writing new Drivers for SqVM

You are here:

I finally managed to build Squawk on windows and ran the tests successfully. What a relief :)

Now, I'm trying to figure out how to write drivers for Squawk. Can you point me to an example or existing driver source because my initial search through the source tree returned only Driver interface, DriverLoader and JavaDriverManager.

Also is there a config file that needs to be modified so SqVM will load appropriate drivers?

There are a couple of options for providing drivers. The preferred way is to write it in Java using NativeUnsafe to bit bash registers. The other way is through the channel interface using ChannelConstants.

Oops, forgot to answer how you add the new drivers. This will be done in two parts. The first here, and the second in a separate post I will make after this.

The command
d rom cldc imp
Takes care to create a bootstrap suite as well as the squawk executable. The cldc imp part of the command defines which classes will be included in the bootstrap. So to add your own code to the bootstrap, you can simply do a
d rom cldc imp mymodule myapp

The rom command looks inside the mymodule directory and looks for a j2meclasses and resources directory and includes the content into the bootstrap. I will make a post on how to create your own module right after this.

Squawk supports suite chaining, but this requires a couple more commands that I can post later. So you could build a bootstrap suite that contains your library based code, and a separate suite that contains your application. The advantage of this approach is that the VM would not have to be rebuild when you modify your application. However, keep in mind that if you change the bootstrap, you need to re-create the VM AND the suites dependent on that bootstrap, which would be the application suite in this example.

You can also specify a .jar file that contains the pre-verified classes you wish to include.