WonderSwan support #2299
Replies: 9 comments 7 replies
-
|
Hello @asiekierka, nice to see around here! :) I would say that the ELKS kernel with no applications might possibly be able to run in 20k+ RAM and 36k ROM, but then it really depends on what you want to do after that. Will you be running the kernel ELKS kernel CS segment and a filesystem from ROM, and then use some extra cartridge RAM to run some applications? I'll comment on how some of those scenarios might be made to work. I haven't had time to look at your hardware overview yet, so we'll just stick to basic kernel, filesystem and RAM configurations for the moment. The kernel itself is easily run from ROM (min ~36k?), and can be setup to run without any BIOS services. A HW timer helps a lot, but neither PIC nor PIT are necessarily mandatory, using special options. The kernel data segment is highly configurable based on options in elks/include/linuxmt/config.h, shown here for a small 19k data segment (normally 64k): An ELKS filesystem can be put in ROM and a ROMFS filesystem driver compiled into the kernel, using various .config options. The entire result can be emulated on the desktop using The kernel itself is going to be at least 36k, so running it from RAM will be more problematic with your limited memory, although I suppose possible out of the cartridge RAM. The kernel doesn't know anything about bank switching, although our XMS (extended memory) buffer system uses a similar mechanism for managing data buffers that aren't directly addressable. The bigger problem comes after kernel startup, when /bin/init (unlikely) or /bin/sh or /bin/sash (standalone shell) are run. Our ASH (bash) shell is huge at 68k and sash at 50k: Sash could possibly be made to run within a system composed of 32k of base RAM and 64K of cartridge RAM, but I'm wondering what else will?! Each application data or code segment has to be contigous within itself, so it can't be split across say, main memory and cartridge ROM, although the code or data segment(s) separately could. This probably means you might just want to run a custom application instead of a shell. That would be straightforward as it'd be pretty much like writing a small Linux or POSIX program, as far as system calls are concerned. Most all the kernel resources, # tasks, # buffers, # inodes, pipe, serial and keyboard input queue sizes, etc. can be sized way down to something like 15-20k kernel data. But even though our applications are seemingly tiny, some are still pretty big, when you're talking 64k RAM total. Much time has been spent removing external dependencies from the ELKS system, especially BIOS and external hardware. More information about that is detailed in Documentation/text/porting-guide.txt. The WonderSwan's PIC and PIT should be ported, but that's fairly straightforward. A new console driver might have to be written, which is a bit of work, unless you just want serial I/O to start. So yes, it is possibly feasible, but still could be a lot of work (and fun). |
Beta Was this translation helpful? Give feedback.
-
|
Thank you! That tells me it's very much within the realm of possibility. As for available memory, here's a more helpful summary: RAM provided by consoleWonderSwan "mono"The WonderSwan "mono" has 16K of fast RAM mapped at
This leaves anywhere between 6 KiB and 10 KiB of contiguous "fast" RAM that can be allocated to various things. WonderSwan ColorThe color model has 64K of fast RAM mapped at This gives two RAM holes: one somewhere between 6 KiB and 14 KiB in size, the other somewhere between 32.5 KiB and 48 KiB in size. RAM provided by cartridge (and etc.)Generally, WonderSwan cartridges came with RAM sizes up to 512 KiB and ROM sizes up to 16 MiB; however, the RAM and ROM are both banked. This means that up to 64 KiB of RAM and 896 KiB of ROM is accessible at any one time. This is a hardware limitation enforced by the console - addresses WonderWitchThe WonderWitch is the official homebrew development kit for the WonderSwan; as such, for reasons of vaguely snobbish accuracy, I'd like to get ELKS running on it too. This cartridge has 448 KiB of user-programmable NOR flash (and 64 KiB of fixed NOR flash containing the cartridge's own BIOS) which could house the romfs and kernel, as well as 256 KiB of cartridge RAM. As the BIOS reserves some console RAM for itself, that 64 KiB window would need to be sufficient for running ELKS on this platform (unless the display is left unused). nileswannileswan is a flash cartridge I happen to be working on. It provides 16 MiB of ROM emulated using PSRAM, and 512 KiB of RAM in that 64 KiB window. In addition, it provides an SPI bus for communication with a removable storage card (which, thankfully, can be easily adapted to ELKS based on what I've seen of its code). Interestingly, if code segments can be guaranteed to be read-only, they could be read into this emulated ROM area dynamically; that is, it can be read like standard 8086 memory, but it can only be written through the RAM window. I am, however, not sure if ELKS makes that guarantee at any level, given we're running in real mode :-) WS Flash MastaThe WS Flash Masta is a popular flash cartridge for the console with 8 MiB of ROM (via NOR flash) and 512 KiB of RAM in that 64 KiB window. No special features are offered. Overall, I feel the best thing to do to take full extent of the WonderSwan would be to figure out if it would be possible to adapt the kernel's process/thread subsystems to take advantage of SRAM banking (and nileswan ROM emulation), by allowing programs which don't share code/data segments to be bank-switched. That is not necessary for an initial port, of course, but it would make ELKS on the platform substantially more usable. Oh, and we also have a networking peripheral... |
Beta Was this translation helpful? Give feedback.
-
Hopefully I'm not sticking my neck out in thinking a minimal ELKS could run in 64K RAM! Building the emu86-rom.config version yesterday, the kernel was ~36k, which if set up for a small kernel data segment +~20k = ~56k. The ROMFS would have to go somewhere else and the RAM for applications could be added to the main memory allocation list from other sources and managed by segment descriptor and length.
Well, certainly this depends on what "guarantee" means :) There are no hardware guarantees, 'cuz we're running real mode. But I can "guarantee" that all the previous code writing to code segments has been removed, and the system doesn't do so... until user applications start running when the guarantee is off... (BTW, application code segments are shared, for what it's worth, and there are no known cases of writing to a code segment).
Indeed, the kernel syscall/interrupt/process subsystem is the (elegant) core of ELKS (there are no threads). Understanding this is key to how the system operates, especially with nested interrupts and kernel re-entry. This has been previously contemplated during a discussion of adding process swapping, and it will be very tricky. The problem with general process swapping is that the swapin address has to be the same as swapout, since the code can't be relocated solely with a segment register switch. But in the bank-switch case, that's a non-issue since the address remains constant. I wrote up a two-part article on exactly how the core task/interrupt processing works; though there's been a slight modification to the actual workings since. |
Beta Was this translation helpful? Give feedback.
-
Ah, but on the Color machine, its total of ~128K of free RAM (64K game console + 64K cartridge) can be neatly subdivided between console emulation, kernel, and userland. And we can of course keep the ROMFS and kernel code in ROM; there's no problem with doing that. |
Beta Was this translation helpful? Give feedback.
-
Status update! Was easier than expected. I'll need to write real drivers for most things, though. |
Beta Was this translation helpful? Give feedback.
-
|
So nice to see ELKS running on another device! Yay! Very cool! |
Beta Was this translation helpful? Give feedback.
-
|
It has been a while! I've decided to come back to the project to implement some features to try and manuever past the 64 KiB process RAM limit:
With these two combined (and a few minor tweaks), I managed to make ELKS on the WonderSwan surprisingly usable: test2.mp4 |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
If I manage to put my hands on a WonderSwan, which kind of cartridge would I need to "burn" ELKS to it? |
Beta Was this translation helpful? Give feedback.



Uh oh!
There was an error while loading. Please reload this page.
-
Hello! As the WonderSwan has the interesting distinction of being a game console powered by an 8086-compatible CPU, I've sometimes been idly wondering if a port of ELKS to the platform would be possible, and would like to inquire with people who have more experience with ELKS about it.
The main catch is that the WonderSwan doesn't have a lot of RAM. The mono model comes with 16 KB, shared between the video hardware and the CPU; the later color model expands that to 64 KB. However, it's not uncommon for cartridge to provide additional RAM on-board; the largest of which having been 256 KB and 512 KB back in the console's heyday.
... But, it's banked. That is:
Of course, this also means that the WonderSwan is not IBM-compatible in the slightest. For a brief introduction to its video/sound/UART hardware, I encourage looking through my hardware overview, as well as the wiki I maintain.
In terms of CPU performance, the 3 MHz NEC V30MZ is a fairly accurate 80186 clone (unlike the V20/V30 family) with fast instruction timings, putting it in the ballpark of a 6-8 MHz, maybe? 286.
My question is, before I dive deep into it myself - does it appear feasible to adjust ELKS to work under these constraints?
Beta Was this translation helpful? Give feedback.
All reactions