I feel like starting an OS. It probably won't get far, but there are a few things I felt I needed to ask.
From what pages can protected ports be accessed? (like flash unlocking, etc.)
What flash pages must contain what? what can't be touched?
Where can I find documentation on accessing flash?
Thanks for any help.
Protected ports can be read from and written to from "privileged" pages or sectors, which include pages: 2Fh/6Fh, 1Ch/3Ch/7Ch, 1Dh/3Dh/7Dh, 1Fh/3Fh/7Fh.
Flash page 00 is permanently fixed in the first bank, or address range 0000h to 3FFFh, so it must contain the boot sequence at 0053h, OS valid markers at 0026h (if memory serves) and 0056h, and the interrupt at 0038h (if your OS has an interrupt, which it almost certainly will).
The boot code, or more accurately the boot sectors, cannot be modified. They include 1Fh/3Fh/7Fh on all models and additionally 2Ch/6Ch to 2Fh/6Fh on the 84+/SE.
The certificate area is Flash page 1Eh/3Eh/7Eh and it's highly recommended that you never touch this Flash page as it's a data-only page, contains calculator-specific information such as the calculator ID and license updates, Press-to-Test/Testguard2/Flash application bitmaps, and other stuff. Corrupting this area of memory also has the potential to permanently brick a graphing calculator (the only known way to do so through software).
You can find documentation on accessing the Flash chip from the chip documentation, WikiTI, and PongOS, though quite frankly, it's not really necessary -- the boot code already has routines that wrap this stuff up for you, such as _WriteFlashUnsafe, _EraseFlash, etc.
I'm stuck. How does dual booting work? I can't seem to figure it out...
There is no standard for dual booting. The only known third-party OS to do it is OS2, and its method is rather involved.
Because OS2 only uses six pages, 00h to 03h and 7Ch to 7Dh, and because there are six pages of Flash memory not currently in use by any OS (pages 6Ah, 6Bh, and 70h to 73h), OS2 can store six pages of itself and the six pages shared with the TI-OS. By swapping between pages 00h-03h and 7Ch-7Dh and the unused pages, it can get away with dual booting. (Note this doesn't apply to the 73 or 83+, which don't have a sector 70h -- they don't have enough space for dual booting and so it's not supported on those.)
The actual swap is fairly trivial -- back up the first sector (pages 00h to 03h) to the swap sector (typically 08h, but can be 0Ch or frankly any sector that starts with byte 0FEh), erase the first sector, copy the unused sector (pages 70h to 73h) to the first sector, erase the unused sector, and copy the swap sector to the unused sector. Then do the same thing involving pages 7Ch-7Dh and 6Ah-6Bh (which is a little trickier since it shares a sector with the beginning of Flash application space (68h-69h)).
To make the swap possible oncalc, there is a specific key sequence you hold on boot. On OS2, this is [ON]+[X,T,theta,n]. Part of OS2's startup sequence is to check for this key combination, and if detected, present a "Switch OS?" menu and do the above.
The problem here is that the TI-OS also needs this key sequence, which requires patching its startup sequence (at 0053h) to check for the key combination, and if not pressed, boot normally, otherwise present the same menu as above.
After OS2 is installed on a calculator, you can place it in a special mode to receive a copy of the TI-OS. This works like a typical OS transfer, except instead of writing the data from pages 00h-03h and 7Ch-7Dh to the actual pages, it writes them to the extra Flash pages instead. It also patches page 0 in memory to include the [ON]+[X,T,theta,n] check.
Needless to say, dual booting is an advanced feature, as is writing an OS at all, so I highly recommend taking your time and not getting discouraged. It's quite literally the largest calculator project you can undertake, and no one has ever successfully completed it.
Hope that helps.
EDIT: By the way, sector 70h is explicitly checked by the OS to make sure it's empty, and if not, it erases it. This check is also patched out of the TI-OS by OS2 when it receives it.
And also, the SVN repository of the source is at
http://brandonw.net/svn/calcstuff/OS2/ if you want to see this nightmarish stuff for yourself.