‫Hello and welcome to this lecture, in this lecture, we're going to change our global descriptive table
‫and boot Dadaism by here into a sea equivalent.
‫We're going to create some structures and see to represent our global descriptive table, and we're
‫going to implement a special function that can load from the C-code instead of this assembly.
‫So let's begin.
‫We're going to start by creating a GDP directory in source.
‫And a directory and build.
‫I will just create a keep file here because I'm using it, you don't have to do this.
‫So now scroll down to our GDP directory and we're going to create a new file called GTE dot org A and
‫FTTH to find Ghetty.
‫And if inside the definition, we're now going to define some structures, we're going to go struct
‫GDC and at the top here, we're going to include as the incident Hajj now put a semicolon at the end
‫of the structure and we're going to go unit 16 T.
‫Segment Unit 16 to base first, unit 80, base unit 80, access unit 80, high flags.
‫Unit 80.
‫Base 24, 31 beds.
‫OK, so this little structure that we've made here represents the structures.
‫We have an assembly here, GDP code, GDP data and so on.
‫So that's what that represents.
‫We've made a C structure to represent this now.
‫Now we don't want to be working with these bits, copying over between 24 and 31 bits and all this sort
‫of stuff.
‫It's just unnecessary stress.
‫So what we can do is we can make a special type of structure that our colonel will use that allows for
‫structured global descriptor tables and then we can pass it through some sort of function which will
‫build the correct GDP for us.
‫So let's do that.
‫We're going to go structure structured.
‫And that's going to accept a unit three to base a unit 32 to limit and the unit eight type.
‫So you can see that's far simpler now when I was going to have some functions here.
‫So we're going to have a void GDC load structure, ADT, GDP and the size.
‫And this will be an assembly function.
‫And we're going to have a GDP structured to GDP, which will convert our structured structure into an
‫unstructured GDP ready to be passed to GDP load here.
‫OK, I'm going to go strug structured, structured, structured GDP in it tells centuries and that is
‫it.
‫So should be entries and we're now going to have to create a file called Tazi and we're going to copy
‫and get structured to get a copy of the prototype fatuity structures to GDP.
‫And in GDP directory we're going to go Gizzi and we're just going to include GDP that, hey, I was
‫just going to paste this in there.
‫OK, so that is our function that we're about to implement now.
‫OK, so we're just going to go for in it I equals zero I below total entries I plus plus and we're going
‫to go encode GDP entry and we need to create this function in a minute.
‫We're going to go unit eight T and this is going to be a cast guys.
‫OK, Ampersand, GDC, I and I, we're going to go structured GDC.
‫I and we now need to create this function and what is functional do is it will encode a single structure,
‫get into a normal GDP.
‫When I say normal GDP, I mean the GDP that the processor can read as as seen in the DSM, these little
‫ones that we made here a while ago.
‫OK, so, yeah, let's create an cogie entry now.
‫OK, so now we're just going to go up here and we're going to go void encode GDC entry unit eighty Target
‫and struct GDC structured source and you'll notice our source variable is not a pointer.
‫This is not a mistake.
‫We want to pass this by value.
‫So what we're going to say is we're going to say if the source limit is above six five five three six
‫and the source limit ampersands zero, faith does not equal zero F f.
‫Then there's a mistake here and we will panic the system.
‫OK.
‫Valid argument, OK, excellent.
‫And now further down here, we're going to say if the source limit is above six five five three six.
‫Then saw start limits equals soft start limits shifted to the right by 12, when I was going to go target
‫six equals zero zero, OK, and now just above here on line ten, we're going to go target six equals
‫zero four zero.
‫OK, so in other words, if this is not true, then target six will be zero 40.
‫And we're basically just building our entry here.
‫OK, so what we're going to do now is we're going to say target zero equals Solstar limit ampersand,
‫Xbox F, so we're ending that on their target.
‫One equals source dot limit shifted to the right by eight.
‫Ampersands, your ex-wife and I were going to go target sex all equals Solstar limit shifted to the
‫right by 16 ampersands zero zero.
‫OK, so this encodes the limits.
‫And now down here, we're going to encode the base.
‫So we're going to go target to ECOSOC stop base ampersands zero x F target three equals Solstar base
‫shifted to the right by eight.
‫And we're just going to go ampersand zero x f target four equals.
‫So stop base shifted to the right by 16 percent.
‫Zero F target six.
‫Now target seven equals so stop base shifted to the right by 24 percent.
‫Zero F and finally we go target five equals four stop type said that type.
‫OK, so that should encode a single digit entry for us correctly.
‫So you can see why we use a target structured now instead of just relying on the GDC provided here that
‫the processor expects because it's quite complicated.
‫Uh, so yeah, we can now start restructuring the T uh and this bootloader stuff will still have to
‫stay because we switch to protected mode.
‫But the point is we can reload it through C at any time, which will be a little more mandatory when
‫we when we implement the task switch segment later on, which is why we're doing this.
‫So don't skip out on this lecture.
‫It seems optional to you now, but it won't be later on.
‫OK, so now that we've implemented encode GDC entry, we need to create a new file and GDC, I want
‫to call it Diesem and here we're going to create LGT load function.
‫So we're going to go Section DOT, HSM Global GDC load and now we're going to go GDC load.
‫Move, ESX, E.S.P, plus four, and now we're going to go move GDP descriptor, which we haven't created
‫yet, by the way, plus two, and we're going to move the X register into here and now we're going to
‫go move X E.S.P plus eight and now we're going to go move GDC Descriptor X and then we're going to say
‫LGT t get descriptor.
‫So you load the descriptor table load GDC the instruction we used in our assembly recently and I was
‫just going to go Rets.
‫So now at the bottom here, we're going to go section dot data and we're going to go to the script which
‫is literally going to go d w zero zero zero.
‫And this will be the size.
‫And then we're just going to go did six years ago, and this is the start address.
‫OK, so simple as that.
‫So if you look in our dot JSM.
‫You can see how we have our scripted by here to understand, so we have essentially just implemented
‫the same thing in GDP today assembly.
‫And if we search in the bootloader for LGBT, LGBT, you can see.
‫It loads it here.
‫OK, so, you know, we're just making a C version of this, essentially a function that does this for
‫us to see.
‫So what happened is then it will go into here.
‫It will copy in the address and the let's have a look at the prototype.
‫It will copy in the address of the GDP and the size of the tape, and then it will populate the GDP
‫descriptor by here in memory and then it will call the load GDC instruction on the processor.
‫So essentially this just loads ARGT guys.
‫That's all it does.
‫But yes, the next step now is to try to implement this in kind of that C so we're going to do that
‫now.
‫So let's head over to Colonel Dot C and just above Colonel Main, we're going to go struct GDC, GDC
‫Real, OK, and we're just going to show us total GDP segments again.
‫We can fill in that value later on.
‫And now we're going to go struct.
‫GDC structured, GDP structured.
‫And we're going to go purchase total GDP segments.
‫OK, equals.
‫And we're now going to fill these in.
‫But before we continue to scroll up and we're going to just include, uh, GDP, GDP, deitsch, just
‫to resolve those structures.
‫OK, um, OK.
‫So picturesque togged segments.
‫We can now fill that in.
‫So we should have three segments at the moment, the No segment, the kernel code and the kernel data.
‫So that's fine if we go to conflict Hajj, which is going to define that here picture as tollgates segments
‫and we're just going to put three in here.
‫OK, back to Canada, but see now when we're ready to continue.
‫So we're going to go open up the brackets here.
‫Top base equals zero zero dot limit equals zero zero zero dot type equals zero zero zero.
‫And that is our no segment.
‫And have we included configured hates?
‫No, we haven't include that, guys.
‫OK, so that'll resolve the Peatross thing here.
‫Oh, and there's a spelling mistake here, so just correct that to Peatross told GGC segments.
‫OK, so that's on those segments.
‫And don't forget these commas, guys, please.
‫So now we're going to go start base equals zero zero dot limit equals zero x f f f f f.
‫So ATF guys dot type equals zero X, nine A and that's our kernel code segment.
‫And don't forget the comma.
‫And now we're going to go to base zero zero dot limit equals zero x f f f f.
‫So the full address space guys dot type equals zero nine two.
‫And there's a kernel data segment.
‫OK, kernel data segment.
‫Yes.
‫You can see this is a lot cleaner, right.
‫Than what we see in the bootloader by here.
‫All of these.
‫And you can see the axis bites here, you know, nine, eight, nine two, so, you know, if we go
‫to Canada at see, you can see that we have nine, eight and nine two.
‫So, yeah, hexadecimal.
‫So you can see how that's working.
‫Guys will now pass GGC structure through a special function that will populate our GDP real.
‫OK, so that's what's going on here.
‫It'll take what's in here and it will populate our GDP real with the ones that the processor expects.
‫We can then call it CTT load on GDP real and it will load the global script to table.
‫OK, suggesting Colonel may now above keep in it.
‫We're just going to go meme's said GDP real and we're just going to go zero size of GDP real and we
‫just need to actually include that as well.
‫Guys include memory, memory dot h.
‫OK, excellent.
‫So that all of them set it to zero.
‫And when I'm going to go get structured, the GDP and we're going to pass in GDP real, we're going
‫to pass in GDP structured and we're going to pass in the total entries.
‫OK, so that'll convert our GDP structured to the GDP real, and it will start to result in GDP real.
‫And now we just need to go GDP load and we're going to pass in GDP real and the size will be the size
‫of GDP, real load the GDP.
‫And we're just going to add some stuff to the makefile now and then we'll try to build this.
‫So go to the Makefile and we are going to.
‫Copy and paste this one here, and we're just going to change this to GDP, GDP, Dotto GDP, GDP does
‫see solid GDP, Chitty Chitty, Chitty, Chitty, Chitty Chitty, OK, and we're going to copy and paste
‫the Nassim one here for Colonel Dadaism.
‫And we're just going to go source.
‫Chitty Chitty Chitty RASM, when I copy this, pasted here and then the Bell director, Big JSM.
‫OK, so now we're going to copy this at the very top here.
‫Now.
‫We're going to just say Paysite in so it goes big.
‫We're going to paste it again.
‫Am I going to change this to get JSM?
‫OK, we're just going to make clean now and then we'll build.
‫And you can see it's complaining.
‫Let's go to our.
‫And we can see the problem here, there is no semicolon on line nine, so put a semicolon there.
‫We're going to rebuild.
‫And we can see there's an implicit declaration of panic that that's, again, is not a big deal, we
‫just need to make sure that panic is included.
‫So she to see and we can see that we haven't included kernels of Hajj.
‫So just include the Hajj and enjoy to see and rebuild that.
‫And we can see there's one more problem here.
‫Cannot find Colonel Sendero.
‫This is a mistake in the makefile.
‫Go to the makefile and we can see here, I forgot to change our directory here.
‫So change this to GDP, GDP, diesem, OK for the assembly fould.
‫So now we go build and we can see that now build successfully.
‫If we could build an kumu, we can see that the program still runs as expected.
‫So we've now implemented the global descriptive table in C and we can literally manipulate the permissions
‫of the entire address space by changing these structures here.
‫OK, so congratulations on that when you're one step ahead to implementing use programs.
‫Congratulations.