 So last time working with the alpha smart Dana I got a debug tool up and running that talked directly to the system on a chip and Was able to do various things download code upload code, etc Since then I have actually gone away and fixed the programs. It actually works, which it didn't then this Chip seems to be quite buggy and the bootstrap mode stuff doesn't work Quite as well as I thought such as for example of the 32 byte instruction buffer that you use to put instructions into Get overwritten on every right that the system executes. So that's not ideal But that should now be working and so today I'm going to start work on the main port of the operating system that I want to run on this thing, which is emu toss No, it's not physics Just for a change This is an open source rewrite of the old Atari toss operating system from the Atari ST which is a quite nice and simple DOS like operating system with an integrated GUI, which you can see in the screenshot here It should run quite nicely on this machine. The only issue is the screen is quite Short, it's only a hundred and sixty pixels and emu toss really wants 200 So we may end up with some dialogue boxes being chopped off But I'm nowhere near the GUI stage yet. Like I haven't even started any work or Really looked at it much So what I'm going to do today is to try and at least get a emu toss image built For the device not necessarily make it run, but it would be nice So I Know this is portable. I've checked up ahead of time It runs on a variety of different pieces of hardware including the Amiga So if it can run on the Amiga, it can probably run on this thing So I need to first Set up the build so I might as well go and copy the Amiga set up Let's just go Dana What is ROM Amiga That's the name of the ROM that's being generated. I'm not actually going to make a ROM I'm going to Produce a RAM image Which I will then attempt to upload onto the device and execute Okay So now we go look for The Amiga image section and we will copy this It should be nothing particularly exciting about the build So every reference of Amiga needs to become Dana No idea what that is. So I'll leave it right. I don't know what look wrong does. It's just it's an executable Which I presume Does the work? Okay, this actually converts stuff into ROM images. So we'll need to update that as well So Do we have No references to Okay so we should now be able to say from Dana and That did not work at all. All right, it built but Then mukram crashes. So let's just clean that and do another build and See what it does That does seem to be building rather more than I was expecting Okay, we're gonna have to work on mukram now So this is the list of ROMs, which we can generate so we simply add Dana to the end of it Duplicate this We don't need to check some actually actually We don't need this at all We're going to generate a generic ROM the command pad version which will just add zero bytes on the end based on The size given. I wonder if we can ignore the zero bytes a suspect We might not anyway, let's Let's go back to the make file. Let's try changing command pad Zero. Is that gonna do anything? Yeah Okay, let's have another look at mukram. I wonder if there's a way to get around Padding The mega ROM image is checked some well all the Amiga stuff is checked some that we don't really care about What's a pack three? Also has padding Okay, let's just add a oh wait a minute. Wait a minute. I'm being stupid Problem solved. Okay, so we now have emutas daner rom which is a Hulking great piece of code It's a whole 280k Which is more than I would like to download over a 19.2 kiloboard serial link Even if I have got the got it working actually at 19.2 kiloboard So we are going to try to chop some stuff off this Now we yeah, here we go so The first thing we're gonna do is to Turn off the AES which is the GUI system. So that should be doable like that does Interesting I get that right. I think I did not get that right Well, here is the code for cart. So that should be interesting, okay Can we set it manually and make something happen something did happen then so intriguing Okay, let's just do that on the command line then zero and Right that fails because So dos you see those don't look like graphical things. They look like DOS based things. So why is it? Why would it be? Why would they be missing I would think with a name like that they would be in there which they're not This DSP stuff looks like It's Hardware specific that I do not want for this case. Yes, look It's obviously referring to some hardware device Okay, so that's being enabled from somewhere We have to turn that off. Yeah, I was never actually expecting Any of this stuff to work out of the box here we go Target defaults Really these should fail it should just fail to build in a sensible fashion if These are not set Okay So by the looks of it we need two of these to find one for the ROM So this is target Dana ROM and one for the machine machine Dana So if machine Dana, then it's not Atari hardware We do not have IDE. We do not have UAE Okay, that's better and it's we're now down to 100k which is better It looks like this is still trying to build all the VDI stuff This is the the graphical interface So let's try and get rid of that the obvious thing to look for is a use VDI which there isn't okay, so Where's VDI source used by Apparently nowhere. So one possible one possibility is that the Configuration I'm interested in is actually in the source code itself But it does not appear to be I Think that these variable names are Referred to Dynamically, so let's look for yeah, here we are right, so This is where it decides to Enable various options, so we want a if with VDI one optional dears is VDI and if and Okay, so now If I build that again, but we're with VDI for zero then Lots of things fail because this is not designed to have the VDI removed. Why is that in the BIOS? That looks like a graphics thing Line a graphics stuff. It is a graphics thing. That's a shame. I think we may have to keep the VDI So let's just take this stuff out again Which makes the whole image rather bigger than I was wanting at a hundred K a Problem is I get about 2k a second download speed so that takes 50 seconds just to load the image into the Onto the device I If I can press it then Yeah So if I can transfer it compressed then that reduces it to about 30 seconds, which is still annoying large amount of time, but Anyway, we have a built an image that is building so Where is that config so Let's go looking for a me go hardware in the startup code. How about BIOS startup that looks like a useful thing So this is the this is the ROM header Which has to be a specific size for the Amiga? We don't care about that So in fact our ROM will start with Should be able to debug it as a matter of fact Well disassemble it Image I have to tell obj dump that I want it. I want to disassemble a binary file Which is Option to specify the architecture here we go Try be binary. I'll support the 68,000. I know that you need to get the name, right? M68k M68k heaven's sake and of course none of these are the actual elf image Okay, both these things are the same File, let me just try and find where it puts the object File from it. Let's get emu to stop image Comes from All the objects as interesting that should actually be Okay, it's somehow figured out a way to generate a binary directly with LD, which is no help for us I do want to try and get the dissembler working so I'll actually Do a bit of offline research for that one Yeah, all I needed was the option to tell it to disassemble everything rather than The only the things it thinks is text Of course, it has no information about the binary so it thinks it's all data Therefore it didn't try to disassemble anything so back to startup.s So at the top of our image be branched to main which is here main is To dress 30 we should find it here Real main is a bit further on Possibly in different object file. Nope. It's here Which is that for e But of course it's decided not to disassemble for e because of multi word instructions so by the first instruction that actually synchronizes with the disassembly We're not getting any of that. So These three instructions Here this one lea. Yeah, this sets the stack so firstly We are probably going to need to Run some of to do our own setup code somewhere in here But we can get away without that for the time being The environment where I download images into it will do all the setup for us There's a nasty script that does it and pokes the registers directly So we don't need to put that into the code for the time being but we are going to need to Set the memory map. So where is That top to find Probably here. Yeah, okay target Dana We are going to load the ROM at There this is immediately after the vector table in the beginning of RAM. I wonder do should we set this? In toss lives in RAM, I think that with this set it will generate a Relocatable object file rather than an absolute object file, which I don't think we want So let's leave that We rather want to put the No, let's do it the way They want and let's see what this does when we build it It's gone somewhere Yep, uh, I don't want Dana ROM. I want Just want target Dana. Okay, that is now different Yeah, so st RAM is the RAM area up on all 68,000 Well, all 68,000s have to have the vector table starting at zero So you either need ROM or RAM at address zero and on the st It's RAM Likewise on this system. We can easily configure it for RAM. So And it's decided to put things Whereas it decided to put things two ones 2140 That's after the variables Oh, yeah 68000 system variables like being below 64k because there's a short addressing mode that allows you to get at them from anywhere Yeah, it's like the six four zero two zero page So that actually seems quite plausible so For okay only start address as matter we have 16 megs Okay, extensive files up to the end of supervisor only ram All right. So what does our image look like now? That looks like it's uh The same branch instruction So I think we have an image that's good to load at the that the target address and then it should work So let's just trace through from real main, which is a 4e Okay, we set sr ignored ignored ignored Load the stack Which is Here is that the right place for the stack? Yep We get stack from 800 to 4k 2k to 4k So there we set up the stack We're not a cold fire or a lisa Reset the external hardware. We might need this So the reset instruction sends a command to all the external hardware to reset it basically I think we can get away without it because our system has just booted and therefore I mean we've just come out of the bootloader. So there nothing has been set up to be reset So where were we reload the stack? We Initialize some things. I think we're here actually Reset the vbr Which I'm not quite sure what it is Yes, we are here And move t0 to vbr Which is here Yeah, I'm going to assume you want that So the next thing is cacr We're here now we are Here this is testing to see if it's 68030 Yeah, what this is doing is it's loading this address into one of the The exception vectors So then if it executes a A presumably an instruction that's not supported It will jump to that the processor will throw that exception. It will jump to that value in exception Vector and we end up here. Okay, so eventually This here is all that code So eventually we end up at this massive But this massive compare instruction Is trying to detect whether it's been reset in various ways I'm going to assume this works and eventually we jump off to the reset vector Which is The reset vector is that actually lives at zero So it's clearly Trying to Okay, what this is doing is it's looking to see if we have a reset vector already set up And if we have done a warm boot if we've done a warm boot Then we know that Atari toss is still in memory So we just jump to the reset vector and restart it That's what this stuff is doing. It's it's keeping a magic number in res valid here If it's not There which it won't be in the first execution Then we jump to no reset which is here and that goes to Mem in it Which is somewhere else Okay, that's all looks quite plausible to be honest now mem in it is yeah some of the bios memory s He did tell it that we wanted To live in ram so that doesn't get executed Okay, this is probing available memory I think i'm going to assume that all works to be honest And I think that what I actually want to do now is to is to set up the debug output And run it for real So we're going to be using serial terminal for all input and output Which I need to find first I did find it before I know it's here somewhere So this is the Amiga code Of which there is not a lot Mainly working with the custom hardware And we know that none of this is being used because It's only compiled if machine Amiga is set So if anything was trying to call to it, we get link failures. We're actually going to want to Create a bios daner dot c Con out maybe I think this is trying to write to the screen Yes, it is So that's not what we want I think Ah conf serial console that's a thing we probably want That will go in here Right be con out K print is clearly the routine that actually Uh write stuff to the console And we want bios bios dot c I should have thought of that So what's this doing? Okay, I actually think that on the On my hardware The beginning of the address space is a bit weird But I don't think that's particularly relevant just now You're warning I do have t Okay, so this is where the bios actually starts up. So we need to make sure that k debug is enabled Let's do that be con out is the Print character to Output device. Oh, so this actually goes through the device driver layer Interesting So I still haven't found the code that's actually Writing Stuff to the serial terminal, but I'm going to guess that's going to be in Chard air init info Serial port this looks Kind of hard wary Yeah Here's where it initializes the amiga serial port So we just copy this to this And now when we build it we should end up with a link error Correct, right now we need to add our Dana dot c So this should be machine Dana Custom registers are going to be I've been working with these a lot actually The urx one is at Volatile u-word ff ff ff 904 And tx is at 906 and we don't need any of them We don't Actually, if you don't need anything it comes up to the RS 232 stuff Okay So no initialization needs doing because it's already initialized We can write when This bit is set And where did I put my data sheet? uart u tx one Is here So we can write when bit 13 tx available is set at 906 Tx is at 906 therefore all we need is this Right in order to write we spin wait until the Serial port is ready And then we write our byte to here We don't want to write to anything else. So we're actually going to do Hope that's a valid name Tx1d equals b And this is irrelevant So that should Be all we need so Okay So there's no conditional assembly. So we do need the if death and if All right So when we build it Yeah, we need a We need a header file too. So we just simply chop out All of the Amiga stuff except the stuff we care about Globally search and replace Amiga to Dana and in lowercase, and we should be done Oh, of course apart from changing that and that declaration of Dana rs 2 3 2 in it And it builds 100k Fabulous, okay So let here let's go to our tool We run the initialization script. All right, and the board was already reset What that's done is it's programmed all the registers needed to set up the ram So that we now have Ram present and I can dump the contents like this And you can see it contains garbage because it's not initialized You can then You just double check the Load address These are variables Here we go os header is 2 140 So we should be able to write utas image o x 2 140 and we upload The link is not checked summed in any way. So Hopefully it will be getting there approximately right I In the future, I'm just going to skip past this Like not even with the black screen or anything because it's really boring But this time you're going to have to sit through it Just so you can see how long it's going to take There are options. I could compress the image and then have it automatically decompress when it hits memory There's pretty decent code for doing that Not in emu task elsewhere Okay, it's there So I should be able to do 2 140 512 And here is our image in memory So now I should be able to do execute o x 2 140 Then immediately Fire up the serial terminal And we're going to see what happens Nothing whatsoever Yay It's exactly what I wanted to see. No, not really I was hoping to see at least something show up It's possible that I need Some more initialization to make KD bug work, so That's to see does the String bios in it appear in here anywhere. Yes, it does So I think it is trying to do something. It's just not Maybe it's not got as far as bios in it I would love to have an actual debugger, but I don't so What we are going to do Is here in startup.c In real main We're going to scatter these instructions through it which should hopefully Hopefully write some tracing So we're going to actually have to Test dot b Oh, we can't do that here because we haven't set up the Stack yet So this is This isn't going to wait for the previous byte to be written out to the serial port Which is a shame So we're probably going to get garbage if it works at all But here is the point where we can we should not have called comf with reset disabling the mmu check to jump To various vectors And then we head into mem in it So mem in it is here. We need We actually need the same wait to dx code This appears to be all the code for detecting how much memory is available. I don't actually know what it does for probing this What we'll find out I hope it's possible that we have some stray hardware enabled no like this stuff for Uh, detecting ram and it's corrupting itself Wow, there's a lot of this I'm pretty sure I'm adding these tracing between subroutines, but that's fine Seems to be resetting the stack here Okay, so We reset the board We write it And we run it Yay, nothing at all Well, like it's still just because I reset the board doesn't mean the ram's gone away. So this Very approximately looks like the right the actual right thing So why is that therefore not doing anything at all? One option is that all the tracing is actually appearing before we've had a chance to fire up the serial terminal And then it crashes So let's go into start up. We'll see and here we're just going to go like this So it should just keep spewing Let's just do this actually So this should just keep spewing zeros since here real port Okay, so now we run it Okay, we've got to here So we're just going to have to do this the brute force way. I'm afraid So you've got a piece of code there that Causes serial tracing to spew out Where do we call mem in it? Are we getting as far as there? That's Here So So I was hoping we could get this all done in one go But it looks like we're just going to have to keep moving that piece of code And then eventually we'll find out the furthest point it gets to But there's a whole lot of I need to reset There's a whole going to be a whole lot of repeated tries and binary splitting Okay to run Good That means we've got to here we've got as far as calling into mem in it. Let's go to memory s Uh get rid of all our old tracing So this is going to be Searching for the ram Where's the Where does it actually get to at the end? Oh, wait a minute. Wait a minute. It goes to It goes to mem done This is where we finish we go back to the startup code. So if we put this in here, let's just change this Then Yes while I was at it. I also Changed the execute command so that it fires up a terminal once it's finished So reset Let me see what happens Okay, so what happens when we run this? fantastic Right we've gone through the memory startup sequence Which is nice. That means we've arrived at mem done. Oh, which is here Right. I mean now we go straight to bios main Right, we should be here And then we go straight into bios in it and we should start getting tracing. So let's just Uh, let's go find out what k debug does shall I so this Calls k info Which calls k printf Native debugging output. Okay. What's this? Oh, right. That's the routine that decides whether to Uh Send the size web send the K print output stonks is one of the emulators this will cause the debugging output to appear On the emulator console. So this is the thing I need to enable In fact In fact, I think I will Yeah, you see this is ultra low-level routines for sending stuff to the terminal So I am going to copy that Because I don't trust the the device driver framework just yet Place cold fire with Dana Dana rs2c2 write byte Can we like can I do write b in a debug print? Okay, we now need to go to config here and print Okay so We set go write and wait And now we run it and see what happens crossing fingers Well, we got a one Why did we get a one? We got that one But nothing happened So See this code looks all right. I don't see any problems there Which suggests that something else is wrong So if I do Dana rs2c2 write bq Like so Then hopefully we'll know a bit more So what does this do? intriguing So k debug. Yeah, k debug is actually enabled here So it hasn't printed anything Let's take a look At what the code actually does shall we? If I can find the object files obj bios Okay, so if you look for rs2c2 write b interesting why Is that not let's just try rebuilding that to see Okay, it's recreated the object file Bios main is the real function. So this should exist Here it is So bios main called bios init And bios init has been inlined by the compiler So we should be here Unless there is more than one definition of bios init and this hash defines There seems to be only one because this Code doesn't really match What I'm seeing in the disassembly. Let's try Uh, is it be compiled it all without yeah, it's compiled the whole thing with no debugging information So let's see if we can turn that on because that will help a lot There's not really any excuse for building without debug symbols being generated Because it it doesn't get added to the resulting binary and it doesn't change the code generation and it gives you vastly better Disassemblies, okay, so here is bios main Ah, right It has actually called kdbug But the symbols don't appear directly in the disassembly because these values all get relocated later Uh, there is a Option to enable them Yeah, here it is So now if after every relocation it actually displays it. I forgot to put that in earlier Okay, so we can see it call rs232 write byte. That's producing the queue that we can see there Then it calls kprintf Then it calls write byte again. So kprintf is not I know what I did wrong So I added this function But I didn't add the corresponding call to actually Use it. Okay. That was my fingers not doing what they were told. Okay right, so We reset the computer Every time I do that by the way I'm reaching over and hitting the reset button that I soldered onto my breakout board and that was wow such a good idea Actually like manually tapping the reset pin with a wire is just would not be tenable okay, uh, so now we run it and Whoa We got somewhere Not far, but it is somewhere Right, we got into processor in it and then it crashed So where is processor in it? In general with porting these operating systems The low level stuff takes about 90 percent of the time And then the high level stuff also takes about 90 percent of the time Right. Oh dear machine code Seeing as this is largely a waste of time as we know this thing is going to be a 68 000 One quirk I've discovered of this thing If I just reset the board is If I fill At the bottom of uh, that's I have to do this in small bits Ah, I didn't read I have to initialize the ram first Okay, so If I dump The bottom of memory So I've cleared this And you can see that there are these ffs sitting In memory and I can't overwrite them And I have no idea what's going on there There's the rest of the memory seems to be fine, but those bits are not so great Um, I don't think this is a 28 Uh, this is the initials stack pointer This is the initial program counter So provided we're not doing a warm boot when it tries to like use these we should be fine And as long as none of this code here tries to Call a vector here, we should be fine. I wonder if I should just hard code this for now Do we have this set? This is a useful trick. Yes, we do have conf with advanced cpu set Well, we know we don't have one So this ought to simplify things a bit Yikes conf with apollo 68080 well Hmm, I don't know why those were set in the first place to be honest. Is apollo 680 If conf with apollo, oh, right. I think I need to clean This yeah, that's better And our image hasn't really got any smaller okay, uh, so You've heard me rant about how I dislike make. This is one of the problems. Um, I changed one of these Uh configuration definitions and it then didn't go and rebuild all the things that needed to be rebuilt So we ended up with an inconsistent build Okay, and let's run this Do what happens Excellent. We got a long way through startup We did get a panic, which is a bit annoying I mean, it's annoying that we didn't get any more information about what the panic was Uh, so vt 52 in it is probably here However, that is actually being said by Biostacy that's here Okay, so we got into vt 52 in it, but we didn't come out again Now this message about the address bus that is wrong Right, but advanced cpu is supposed to Like if we don't have an advanced cpu then assumes we have a 24 bit address bus I think that is fine We are going to want I'm going to want eventually to configure the processor to use a 24 bit address bus Because I don't need any of the 32 bit features and there's a little bit of Atari software that that needs a 24 bit bus I'm just hoping that it's not going to do anything That requires a 24 bit bus So we need to find out why This is dying Possibly because we haven't initialized any kind of screen See, yeah This is why I was hoping to not start up the graphics system Right, I bet I know what's happening Which is that the frame buffer is being set thinking it's an Atari system And it's all going horribly wrong So let's Do this let's just try This is only missed to see what actually gets produced So Right this entire This entire function is this code here. It all just goes away Which is good So we probably want to put in here somewhere Dana screen in it I don't actually want to make the screen work at this point. I want to use the serial console I just need to keep it happy enough not to crash later Okay, so let's take a look at what a meter screen in it is doing So what we have got here in the Amiga code is we set a video mode This is all Amiga stuff And in fact nothing happens This is all setting Um This is all hardware setup. So That just becomes nothing over here in screen See the next thing that looks suspicious is screen in its address Which initializes the Uh The frame buffer itself So we can either have a hard coded address Or it Figures out The size of the frame buffer and allocate it dynamically And that is what the code here is doing So initial VRAM size You know What's that actually originally Yeah, okay, that was originally if def That's a bit dubious. You should use consistent users Otherwise you get confused the way I did. Okay. We need Screen in it and initial VRAM size You've got Dana screen in it. I have saved that Oh That's initial implicit declaration Should be using the compilation flag to forbid implicit declarations Okay So we not want to know the size of the frame buffer well Dana initial VRAM size The screen is 540 by 160 and it's monochrome single bit So it is that many bytes Okay Before we run it again, let's go back down to the screen and let's see where the amiga is Doing things This allows you to change video mode, which we don't have initialize the screen if def machine Dana false Get current mode info Get current mode info So Actually, let's just do one plane 540 160 Just the same as the L. There's the Lisa down here palette size monochrome only pixel size Okay, so pixel size is To deciding whether the pixels are square or tall and skinny These old machines tended to use tall and skinny pixels because The standard resolution is like 640 pixels across by 320 high Which gives you 80 by 25 8 by 8 characters However, our screen uses square pixels So I have no idea what these numbers are. So let's just call the Get standard pixel size function. I think here we need to do this Can you really Change the address? I mean does a Atari Toss let you change the address physical screen. Well, we can actually do that. So Set screen, I think that's right Yeah, I'm not quite actually sure what that will do Set color we are going to ignore I mean it's monochrome I don't think we need to do anything here because res changeable should be false Yep And I think we are Done Okay, we need to implement a bunch of stuff Fizz base and set fizz well these don't too much So what is Amiga screen base for? It's a pointer right this because the Amiga is using the The copper coprocessor To read from the frame buffer. So this got actually got the address of the physical frame buffers pointer Hard coded in the copper code So all you need to do is update this and the frame buffer will change We will have to be a little bit more clever, but for the time being Let's just Do it like that Okay Reset the board do a right and let's see what happens now Okay, so let's see what happens Well, I know this is wrong for a start That is not a good address So where is it getting that address from? ebas add Okay, we are someone who's just called set screen with the logical and physical screen addresses Probably screen init address Ah, no, we are actually here Uh, so we have Tried to allocate some Okay I think what this has done is it hasn't allocated memory from ram I believe that this has allocated address space Expecting the video memory to show up there when it gets mapped But let's go look for bia lock st ram That is in Mem No, actually I was wrong there So fizz top is supposed to be the top of actual ram The screen's allocated from the top of that therefore for this value to have been produced Then it's all gone horribly wrong So let's turn this on. I think the memory Detector has mis-detected Ram So let's see what comes out Okay, and run it Right, what do we see? uh Well This is wrong These are all values that it's got from the rom itself. So they will actually seem to be They look plausible So, yeah, it's clearly detecting memory incorrectly so Mem top equals fizz top Where does that come from? maybe My responsibility To set that because I've told it is running out of ram Therefore, it's may may expect the the front end the thing that actually loads the The image which is normally, you know, like a Um a program loader Maybe it expects that to set the various values Because this garbage value does look kind of like what was originally in ram So I can actually figure this out By dumping This okay, so we see that we go from mem in it We initialize the flag and then we go directly to mem check Which is here We skip all of this except this Then we go to here where we Look for magic numbers Then we go to st ram detected, which is I think way down here. Here we go Yeah Right, we it has in fact, we do actually have to tell it what the Top of memory is we should be able to do that in here Uh, or rather in Here somewhere which should be Actually, I'm not sure that is the right place So this is the startup code Is there are are there any romega references? Yes, there are What is this? Right, this is how that we tell Uh Emutos what kind of machine we are so we're going to have to yeah, let's just do that Now With is there a comf with Dana? No, there is not Okay, so we're going to need to copy one of these Dana this becomes zero Okay Okay, uh, yeah, let's go go back to here um machine in it sounds Plausible, but I think I will put it here So in Dana dot h We Do And then in here we We've got 16 megabytes of memory. So that is 16 by 1024 1024 However, I'm a little concerned about The warnings I was getting a moment ago Ah, this is of course an address And the integer overflow was coming from here Really is this Surely this is not defined using 16 bit integers. I think it was, you know, okay So reset and right So we run it and Much better. Okay Uh Memtop is now here at 16 megs We've allocated some memory there We still get a panic Do we have 16 megs? I did look the chip up. Maybe I misread the number That to eight meg and see if that makes a difference But at least now giving us a useful address error with Uh You know the address that caused the problem And where we were when the problem happened So let's try with eight megs and see if that makes a difference Okay, so Execute Um, oh, I know That is a odd address And I bet it's just tried to I bet it's just tried to Write a word to it So 4520 is 45 blank out, right? He's actually trying to write to the screen at this point Interesting. So this is all now generic code. Why is it complaining about Potentially unaligned Accessors But we shall actually We set the board and try and dump that address Okay, that's working. That's doing Wait a minute. That's not the right address Okay Dump here uses byte accessors. So it should be fine So one three was there Okay, where is blank out? con out Who's reading with the background color? 4520 which is the Where the exception happened is fairly near the end. So I'm gonna guess that it was probably this. So where is it getting that address from? There perhaps It's the sick does the six eight thousand require alignment. I do not know. I will go look that up Yes, it does So This address here should be aligned. Otherwise This cannot work So cell adder convert cell x y to a screen address 540 is not a Round number Currently assumes the font width is eight bits. So Okay, so what is 67 by 8? 536 so let's try that Let's see if that does anything it's that is still an odd number of characters See the Lisa here is Is 720 Which is 90 characters Hmm Okay, so now let's try it Same problem So our base address is aligned Our video RAM is well, there's a number I'll put that back to 540 Uh Hang on a second. Hang on a second. I'm just wondering what the chip select registers are initialized to Uh Four mega flash and eight mega RAM. Okay That should be right You see this this sets the mapping of address space to the various memory blocks on the system So this is telling it that the RAM starts at zero and is eight meg long Uh, I was wondering whether this was set to a small nerve value I Will actually do that Because I am not at all sure that I'm interpreting all these bits correctly in the chip select registers So that is Okay, it is doing Precisely the same thing at the same offset. So Yeah, okay, let's figure out exactly what instruction that's happening that's happening at Um, unfortunately because we do not have an image with a Elf file, I cannot just disassemble it hang on a second Interesting so How does it know it needs to write out a binary file? Uh, it could be the Yeah, here we go So I need to do No format I think this will list the no it won't it doesn't produce Elf files, but I might be able to make one of these Hopefully that will contain the Debug information. Okay, it's not a Elf file, but So now I should be able to just do New task There we go So we are at four five two zero Wait a minute two zero two zero. That's Not where I was So six e um I am confused So these addresses don't look right to be honest And let me just double check that so blank out here. So this says it starts at forty four four three zero. So Four four three zero So four five two zero is Somewhere around here But there is nothing problematic about any of that code This source code looks like garbage There's just this routine blank out. It's got nothing to do with any of These lines of source which is irritating But at least we've got a disassembly as to what's going on So This is the address. It's complaining about accessing And there are no instructions around here that would be doing that So this is a Integer add instruction To address registers This decrements d five and conditionally branches to four five one h is there I have no idea what the st instruction is Let me look that up Set according to condition So st set on true set always it sets the The destination to ff. It's a weird optimization So what this is doing is it's setting The thing at this address to ff, which is a two which is zero one Two But here you can see the address we're worried about is in a zero Something is not right here I have a feeling that that line is not doing what I thought it was. So let's get rid of that and let's There we go And let's just take a look at the raw object file Of course, we don't have any addresses handy, but This does indeed look different Okay, right, let's do this the way you should have done before Right blank out is at four four thirty And pc is four five two oh so four five two zero minus So four four thirty Is it offset f zero? This is at one eight c So we should see our instruction at two seven c So eight nine a b c Why that would be producing a Exception I don't know but this is indeed a unlined right And in fact So if Yeah, I I don't know how this could ever work. This is a unlined address And then this is trying to use unlined accesses to write to it And 68 000 can't do that so either there's Something deeper going on or This code doesn't do what I thought it Ah Must be even must be odd Right, that's why it works So cell agile is returning a unlined address because something is Not aligned I just need to make sure that we can do these integers Yes, we can oh we can do p for pointers, which is good Yeah, I think that our screen is a Invalid size so let's put that back up to eight until we know it works. This can be Um It's 480 V car off is that And let's try this Okay run That's a lot of you but Okay, that did indeed hit an address error But it's all Mangled with the rest of the tracing I also forgot to put a New line Yeah, so what have we got? Uh base address displacement is x and y x y zero You see I Don't see Any reason why these would be unlined I mean it's not even as if the screen is set up Skip non-region area with stride advanced that also Needs to be Aligned where does v lin were come from? Interesting. What's this? v lin were bytes per scan line Is 80? I mean it's wrong, but Wait a minute. No, this is hardware specific so Something should be initializing this where is the for example The amiga Initializing it is it in the vdi code. I think it could be Here it is Hang on I can do better than this pti control v lin were equals update res dependent So this is the Horizontal resolution Times number of planes number planes is one and this is Uh this where is that value set is that uh It is a variable It's set by this screen get current mode info and the results are put into these variables so Get current mode info interesting That's and that is in fact a different function than the one I was looking for this one Ah Okay, so this needs to be a aligned value otherwise everything goes horribly wrong This is going I'm going to have to a lot of work on this to get the screen actually working But for the time being let's just try and get the system up and running We're actually most of the way there. I'm really surprised I mean, we've got the exceptions all being handled. We've probably got interrupted by now I didn't do anything We probably don't have a timer No, there won't be a timer because the 68 000 won't actually have one Won't have a standard One it's part of the actual implementation. So I need to figure out where that happens Anyway, let's just try running this Right, we have got further on Ah, there's the timer. I wonder what that does Right, I need to provide it. I have no idea what mfp is But it actually it looks like a standard timer module So possibly we've got one That would be nice Because I don't see anything there about the Amiga so xp timer is here mfp base multi Frequence See something which is set up Here Okay, so let's go over look at our data sheet general purpose timers Is it 600? So do we have anything at ao? So the lcd hardware is at ao and there's nothing at a 80 So we are not using the mfp timer module That is a shame Right, we're going to need to do our own custom timer module So Our timer was in It was in fact in mfp.c Is the mfp enabled by default? I somehow guess it is No, it's not Yeah, a lot of these things should have an else No timer not defined So Okay, so what do we have to do to initialize the timer? Well Let's look at the lisa code That looks pretty simple These are two via clock Yeah, hardware is Not my favorite stuff. Okay. What have we gotten this thing two? identical timers With interrupts restart and free running that's simple enough A restart timer is when the timer reaches a particular value it resets to zero Free running mode is the timer continues running indefinitely and just wraps around when it reaches the maximum Restart mode timers allow you to generate periodic interrupts at any arbitrary interval, which is just what we want so So i'm going to have to go and actually figure this out and also go and look at the Palmos ROM disassembly, which i've got and figure out what it's doing But i'm actually more interested at the moment I think it's more fruitful to figure out why We're crashing after init c port and if you should hit sound init What is conf with scc and do we have it? We do not have it. Okay, so init c report is crashing somewhere Well, we should have initialized the The daner serial port hardware. So What else could be going wrong? Okay, let's disassemble it in time on a tradition and figure out What code is actually in here? Okay, so This initializes Some structure that defines the serial port Then we skip all of this nonsense and just call the daner initialization code Then we do this stuff. Right. I know what's going on here Which is that we have not set up all the callbacks Defining the device Nope, i'm wrong. There is nothing here. So in this case, how does it know What routines to call? This mem copy right that mem copy contains Contains all the initial values for the rs 2 3 2 buffer, etc. All the stuff that makes the device work Then over here we seem to have tables of callbacks That actually make it do things So do we have this? No, do we have that? No Yeah, I still think that nothing is setting up those callbacks. I don't know whose job it is to do this uh iorek appears to be the data But the callbacks are Let's actually go and look see what what that structure looks like No callbacks so When this is actually calling something I bet this is the thing that's failing RS conf pointer rs conf one s conf one is this Okay, this is not doing anything for us, but that's fine. We don't want it to do anything At least for now But that is like a valid thing brute force time underscore underscore line Returns the current line number So we can simply scatter these throughout the code And we should get some stuff coming out So reset and upload and let's see what happens Okay, so when we run it, what do we get? I forgot to put the new lines in uh, okay, so The last time We got to here therefore In its report returned, um So have we died here? So I think the serial port stuff or what worked and it's the Unless it's managed to corrupt its stack which does happen So here is the code that In its serial port Well, that's the that's the kd bug just before that Then we in it the serial port Then we update the boot status and that's a perfectly valid pointer And then we get on to sound in it. So There should be nothing there that causes problems. You do wonder whether it might be Trashing its own stack, which means that the When this function returns It will jump into nowhere, but then I would expect to see some kind of panic appear So what's this doing? Okay In its report, we're in bios.c line 411 So we've printed that But we haven't printed anything else So here is our 411 and then we should be printing 682 So is it This no, there's nothing wrong with that. That's uh, that is an aligned and an aligned address Let's just be absolutely sure Okay, and run it Yeah, it somehow something Doesn't like this. Um Let's just try this it may be a timing issue some description So it just so happens that it's dying a little bit after This Or you know corrupting memory or anything like that I wouldn't expect it to look like that. It was corrupting memory though. I would extend. I would again expect to panic all right, and what this does is Goes quite a long way further on It doesn't like updating boot status really Why it calibrate delay block devs os in its Finish with bios in it. We've got all the way through bios in it But there is nothing at all Controversial about that line of code It's as simple as you can get this That's deeply deeply weird ac6 is The address of boot status Which like you can see it's been correctly set just up here So why is it allowed there and not further on? odd very odd, okay, but we've reached the end of bios in it So I think we go back to start up Oh, no, we don't no, we don't we're still in bios We should have hit Processor in it. I thought that would happen early sound init keyboard minute init acia vex We don't have an acia and we don't have any midi in it acia Uh, okay, I don't think this is hardware. I think this is No, this is hardware Do we have that? No, we don't that's good. Okay. These are internal vectors. They've got nothing to do with the hardware. So that's fine midi Don't think we've got any midi We don't have any midi. So that's fine, too Okay, so we go to calibrate delay Requires interrupts to be enabled. Well, we don't have the timer Block dev init After block dev init Power port after clock init OS init for x mad alt whatever that is After x mad alt we are here Bios init end So I would then expect the next thing that's happened is Dana init But there's nothing here No I'm looking at the wrong place. Yeah, he's getting moderately late. I'm gonna have to finish soon I want to be here where bios init is called Right, so These messages down here are not mine. They're from the kernel These ones are mine, but we know we've got past boot flags here. I Think to be honest that it's actually trying to Run the graphical environment on an invisible screen That's what this is Possibly doing We should have the Yes, we've got the cli and this is supposed to start up console and run the interpreter I want to persuade it to Do this so it enters the cli before doing anything else So in fact, we probably want to do this with this Let's see what happens All right execute Okay, we did enter the cli We got this line of tracing I actually like to know what goes on further down here. So let's just put this in standard is Who knows what that is a Right the load flags Okay So I think that this is actually trying to run something Why nothing's happening. I don't know Let's let's just get rid of this tracing because you don't need it anymore And I wonder whether there is something I need to do to make the console appear here Has it just printed stuff to the invisible screen? It's a com serial console appears to be the thing But why how do I actually get it to show up? I keyboard seems to be the keyboard Is it also the output console? Does not look like it to be honest Okay BT 52 So if we have com serial console and no Com serial console and see that seems to be the simplest configuration Do we have it? We do not so let's go to our Config and that one needs to be unset so It hasn't got much smaller to be honest But now we should be able to go here and do that Okay, there is an error. So that should be going to be con out Where is where does the con outs live not these? I would expect it to be in char dev honestly Or in bios bios perhaps So I think it's going through here Let's and see what happens Okay, and what this does is Yep, it has indeed printed lots of stuff to the console. It just hasn't shown up So what are we seeing? II II Are we sending it to two handles? Where? Come to emu con 22 version Yeah, okay Right, so it's working I think That what's wrong here Is that nothing is hooking up the serial device to these routines Something needs to be doing that otherwise it's just nothing's going to happen So let's take a look at that amiga thing again So where does this happen? Wait a minute Is the i keyboard actually the Screen okay, let's put that in but let's take a look at this first. Okay Okay Simulate right B. I have no idea what that is But let's find out where that's called from i keyboard is in i keyboard i keyboard right B Send a byte to the i keyboard Um, I am actually increasingly unconvinced by this I don't even know if the amiga Serial ports hooked up. What about that? Is that used anywhere? Here it's used here hmm See I would expect that Something would be Trying to read from The serial port as this Yeah, this is setting up an interrupt So that when anything happens on the serial port, this is called which sticks stuff into the Keyboard buffer. So I think comp serial i keyboard is the thing so So let's get this and stick it in here And I think we need to enable Serial i keyboard and let's try that and see what happens All right, and what does this do? not But um no not much And of course, I forgot to turn and tracing on here so that we can actually see whether anything there is happening Uh, it's also possible that It's just the serial port is not supported on the amiga. So Where would I find? real Atari hardware called fire, maybe I mean no, that is not real Atari hardware, but There may be more of an rs 2 3 2 Implementation So here's the interrupt handler for the serial port. So where is this used? It is used in the serial port here Yes handle one Conout one. Okay. Ah, this looks like it L if defined And Sheen Dana Dana rs 2 3 2 B and I also need to update this And if defined Machine Dana Dana rs 2 3 2 can write Okay, now I think that ought to work so I will actually Live dangerously and turn that off And I think I wanted to go to con out I don't remember where this tracing is coming from There it is Okay, now let us try this and see what happens all right execute brilliant Welcome to inucon version 20210819 type help building commands invalid drive Uh, yep, so The invalid drive is because I haven't actually told it about any drives yet We can't type of course because I haven't set up any Input And I think that does have to go through i keyboard. I I'm going to go look up how this is actually supposed to work But I am going to call that a day because that's a good lot of stuff And I'm going to chop out all my extraneous tracing And submit that we have the os actually running. It's not doing much, but it does actually has actually started up apart from that really weird thing about the Uh that boot status or thing Don't know what was going on there but Yeah, so I will come back next time. Hopefully with a little bit more working and Uh, hopefully after having read up on how timers and things work because At this point, I'm going to have to start hooking it up to some hardware I hope you enjoyed this video and please let me know what you think in the comments