DOL - Dynamic Object Loader
stevenmess2004
Posts: 1,102
DOL is now successfully loading an object from an SD card and running it!!! So I thought that I would start a thread for it.
I will keep this post updated with the latest version.
New beta version of DOL2, haven't updated version number since basically nothing in DOL itself has changed, just the demo that comes with it. Much improved but its not finished yet. Dump all the *.dol files onto your sd card. TV needs to be on pins 12+, keyboard on 26+ and sd on 0-3. I'll update it to include the spec soon . Then load SDM_DOL2_Core_V001. You should get a Hello world message. Then type in "upper" and after a short period of time the screen will stop displaying new stuff. This loads the file upper.dol and gives it access to standard input, output and error streams. If you type on the keyboard you will see the stuff converted to uppercase (but don't try anything other than lowercase letters, it just adds on "A"-"a"). You will also find a file in the zip that has a basic object tree that I've been working on. All the stuff below is old but I'll leave it here at least until I get this version finished.
DOL can
- dynamically load objects from an SD card (reasonably tested)
- dynamically unload loaded objects from memory (reasonably tested)
- allow loaded objects to call other loaded objects (reasonably tested)
- give access to system functions such as
--file access (reasonably tested)
--heap access (reasonably tested)
Current version V_014
-Should be able to be used.
-Requires an SD. You need a TV and mouse for the demo.
-See DOL readme in zip file for instructions.
-Loads a file from the SD card and displays "Hello World!" on the TV demonstrating loading a TV driver and running it.
-Converted the mouse driver. Not all of the methods are callable but there should be enough to be useful.
Issues
-Setting freed memory to zero was causing an error so it is now commented out. I'll try to fix it for the next version.
Next version
-More testing.
-Maybe a keyboard and mouse driver.
Thanks to
-hippy for all his work on spin op-code and object format
-Mike Green for modified version of fsrw
-Peter for his heap object
-Chip for making such a great chip
Steven
Post Edited (stevenmess2004) : 7/11/2008 1:21:57 PM GMT
I will keep this post updated with the latest version.
New beta version of DOL2, haven't updated version number since basically nothing in DOL itself has changed, just the demo that comes with it. Much improved but its not finished yet. Dump all the *.dol files onto your sd card. TV needs to be on pins 12+, keyboard on 26+ and sd on 0-3. I'll update it to include the spec soon . Then load SDM_DOL2_Core_V001. You should get a Hello world message. Then type in "upper" and after a short period of time the screen will stop displaying new stuff. This loads the file upper.dol and gives it access to standard input, output and error streams. If you type on the keyboard you will see the stuff converted to uppercase (but don't try anything other than lowercase letters, it just adds on "A"-"a"). You will also find a file in the zip that has a basic object tree that I've been working on. All the stuff below is old but I'll leave it here at least until I get this version finished.
DOL can
- dynamically load objects from an SD card (reasonably tested)
- dynamically unload loaded objects from memory (reasonably tested)
- allow loaded objects to call other loaded objects (reasonably tested)
- give access to system functions such as
--file access (reasonably tested)
--heap access (reasonably tested)
Current version V_014
-Should be able to be used.
-Requires an SD. You need a TV and mouse for the demo.
-See DOL readme in zip file for instructions.
-Loads a file from the SD card and displays "Hello World!" on the TV demonstrating loading a TV driver and running it.
-Converted the mouse driver. Not all of the methods are callable but there should be enough to be useful.
Issues
-Setting freed memory to zero was causing an error so it is now commented out. I'll try to fix it for the next version.
Next version
-More testing.
-Maybe a keyboard and mouse driver.
Thanks to
-hippy for all his work on spin op-code and object format
-Mike Green for modified version of fsrw
-Peter for his heap object
-Chip for making such a great chip
Steven
Post Edited (stevenmess2004) : 7/11/2008 1:21:57 PM GMT
Comments
Is it possible to use a hash function for the object/method names instead of constants?
We could then use
callobject(hash(string("objectname")),hash(string("methodname")),arg1,arg2)
Here are some·hashfunctions
http://www.cse.yorku.ca/~oz/hash.html
methodRunner case would change to
· case methodname
··· hash(string("init")):
··· hash(string("run")):
··· hash(string("stop")):
For objectname you can of cource use the filename.
That really should improve readability (and solve maintenance issues).
regards peter
The only downside is that it adds a lot of run-time overhead doing the hashing on every call and throughout that case statement every time. Ideally a built-in string hashing function for the PropTool is needed here, or macro support, so it can be done at compile time.
It might be possible to do a JIT hashing to speed things up. The string pointed to has the first msb clear if it is character data ( assuming ASCII characters =< $7F ), and the bytes in bytecode could be turned into a hash and written back with msb set. Care would have to be taken with strings less than three characters and the hash wouldn't be long aligned, so there may still need to be a fair amount of bit shifting.
Added : Or change PropTool so every string is only ever generated once. Then the address of the string is its hash. I can think of a few possible cases where that would be undesirable, and in those it can be worked round. - Won't work because the loadable object has its own strings and will not be the same as the loader does. Oh well.
Post Edited (hippy) : 1/14/2008 1:17:04 PM GMT
quite some time to load an object. The objectname can be converted
to a hashnumber, that hashnumber loaded into a free entry of objectNameList[noparse]/noparse,
and if object present on SD and enough·memory and a free entry available,
loadObject can return the entry number 1-16 (handle) or null (object not loaded).
The handle can be passed to callObject, making the search for the entry
obsolete which saves time. That handle would also be passed to unloadObject,
again eliminating·a search.
Edit: in fact, objectNameList[noparse]/noparse can be eliminated alltogether, as objectStartPtr[noparse]/noparse
holds a nonzero value for a loaded object, or null for a free entry.
regards peter
Post Edited (Peter Verkaik) : 1/14/2008 1:52:25 PM GMT
Good to have some feedback from some others Time to start some more fixing.
Steven
PreSpin:
http://forums.parallax.com/showthread.php?p=655470
SCCuM:
http://forums.parallax.com/showthread.php?p=654555
Steven
Post Edited (stevenmess2004) : 1/15/2008 10:47:27 AM GMT
Steven
* You cannot upload files that use MIME type : application/x-zip.
I remember me and a few other guys from around here talking about how something like this would help development of large programs.
Thanks Steven!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Share the knowledge: propeller.wikispaces.com
Lets make some music: www.andrewarsenault.com/hss
Steven
I havn't had a single bug with it yet.
Great work Steven.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Share the knowledge: propeller.wikispaces.com
Lets make some music: www.andrewarsenault.com/hss
Steven
I hope you find it.
So far I havn't found a single bug, So that's good.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Share the knowledge: propeller.wikispaces.com
Lets make some music: www.andrewarsenault.com/hss
Steven
I'll give this a try later after work.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Share the knowledge: propeller.wikispaces.com
Lets make some music: www.andrewarsenault.com/hss
Some help would be great.
Thanks
Steven
I am about half way through the next version of DOL which will allow for an inheritance and only loading VAR sections if the PUB and PRI sections are already loaded.
The build process goes like this.
1. Compile the following files and save them with the following names. Then dump them onto your sd card
- terminal - terminal.dol
- tv_text_DOL - tv_text.dol
- comboKeyboard_DOL - comboKey.dol
- upperCase - upper.dol
2. Compile SDM_DOL2_Core_V001 and load it onto your propeller.
When it starts, DOL loads terminal. Terminal then loads tv_text as the standard output and standard error output streams and comboKey as the standard input stream. Then it waits for you to type something and loads that. If you type in "upper" it loads upper.dol and calls the start method with the standard input, output and error streams in the argument list. Upper then just echo's what you type to the screen using the standard input and output streams that it has been given.
Plans for the future are to
1. Finish DOL2 so that it unloads objects and a couple of other things
2. Reorder/rename methods in the rest of the objects in the object tree file so that we can use more things as stdioe
3. Write a pre-processor that fills in all these numbers and generates headers automatically.
4. Write a post-processor/fix dol that gets rid of the header objects in the binary since they are just taking up space.
5. Fix inheritance either by playing with the method table (hard but faster) or calling the parent object with code (easy but slower)
Been looking at a way to do a download/save to disk via serial port. This would be to make updates more convenient than they are now (thank Tom for not caching the SD card driver ... no choice on "safely removing" on windows though). I have working download "client/server" code from another project. Do you have a serial DOL?
The basic methods you have for console services are interesting, but not having a basic driver suite is limiting. Being able to "extend" objects is interesting and a desirable alternative to the simple unixy file handle way, and I can see how it can be done. You know it will be difficult to design as well as use. Having the template headers is desirable for detecting buggy calls at compile time rather than crash time ... considing only one long per method, I don't see how getting rid of them is a win unless it is an option for deployment -vs- development.
You should seriously consider the one line printf ideas: http://forums.parallax.com/forums/default.aspx?f=25&m=277986 Modules snprintf+itoatoi adds 301 longs for first use, but having many tv.dec, tv.out, etc... is fatter after a point and quite inconvenient. Eliminating blah.dec(n), blah.hex(n,d), etc from the stdout/stderr requirement is a win.
You have a reasonable and expandable piece of work here. I think good communication of your design and usage could make it more embraceable by a larger piece of the community. Being able to easily replace components is a great advantage and will be very welcomed when the mythical PropII comes (which because of many items, makes a larger general computing platform possible).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Getting rid of them gets rid of the need to maintain two copies of the same file for custom objects (its too easy to change one and forget the other). You would still need them for the standard objects.
[noparse][[/noparse]qoute=""]You should seriously consider the one line printf ideas: http://forums.parallax.com/forums/default.aspx?f=25&m=277986 Modules snprintf+itoatoi adds 301 longs for first use, but having many tv.dec, tv.out, etc... is fatter after a point and quite inconvenient. Eliminating blah.dec(n), blah.hex(n,d), etc from the stdout/stderr requirement is a win.
I could make it so that the snprintf object is passed in the parameter list like the stdin, stdout and stderr objects. Could add a str output to the standard output and get rid of the advanced input/output routines which would save space.
Yeah, once I get the terminal working better than I'll start writing some documentation and some better demo's. Maybe I could write the pre-processor for it Only problem is that we can only have one file open at a time on one sd card. It should be possible though to load another complete driver for an sd card on different pins.
Tried a few things yesterday. The upperCase.spin file has a reference to Simple_Serial in it; I could not get that to work. I tried creating a serial_DOL as attached, but that doesn't work either. In american football terms: it's 4th and 10, all I can do is punt. Have a look please.
Thanks.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔