‫OK, so hopefully you're all starting to get excited, we're now going to discuss the interruptive script
‫table.
‫So as you may have gathered from the name, the descriptive table is what is in charge of interrupts
‫Wallstrom protected mode.
‫So when we're in real mode, you know, we used enter of vector table so we could set up Interrupts
‫and Ango things like five and it's six.
‫While the descriptive table is protected modes equivalent.
‫It is hard as set up, but bear with me as I explain it all.
‫OK, so what is the of the script to table.
‫Well the intro to script.
‫The table describes how interests are invoked in protective mode.
‫It can be mapped anywhere in memory and it's different from the interest vector table.
‫So when are we going to explain all of these points?
‫So as I've said, the interest to script the table explains how we set up interrupts, such as in five
‫inch, three inch, 10, 12, so on.
‫So the table is essentially a bunch of intricate descriptors.
‫So you can think like an array of descriptors.
‫Right.
‫And the interrupt script explains the interrupting question.
‫You'll notice there's no interest.
‫No.
‫Here.
‫That's because it is incremental, like the interest vector table.
‫So the actual interrupt itself is based on offset, but we'll get to that soon.
‫So here you can see the actual structure of the descriptor.
‫So we have our offset here, the upper offset bit, forty six to sixty three.
‫And this is the higher the higher part of the offset that we wish to execute.
‫So bid sixteen thirty one here.
‫Right.
‫And here where I mentioned bit, this is the actual bit in the script where we store that offset.
‫So essentially what I'm saying here is in, in bits forty six and sixty three of the script, we are
‫storing an offset which represents the sixteenth to thirty first bit of the higher part of the offset
‫to execute.
‫OK, so I hope that makes sense.
‫However you will see as we go along anyway so we can see 47 is the present bid.
‫So this should be set to zero for any interest we're not using.
‫OK, now the DPL, the script privilege level, this is the ring level that the processor requires to
‫call the centre up.
‫So if you remember in the first lecture for protective mode, I explain what project was we briefly
‫went over security rings.
‫Right.
‫You know, ring zero, ring three and so on.
‫So this is a descriptive privilege level that is required for anybody that is invoking this interrupt.
‫So the script, the privilege level is pretty useful.
‫If you want to have a kernel, only interrupt and interrupt.
‫That can only be called from the kernel itself.
‫And then somewhere down the line you could have a user interrupt then, which can actually be called
‫from userspace like user applications.
‫And when I say kernel space, I refer to things running on a privileged ring.
‫And when I say use a space, I refer to things being run on a unprivileged ring such as ring three for
‫user applications.
‫This is the storage segment.
‫This should be set to zero for trap.
‫Gates will explain more about Gates later on.
‫The type in the script is the actual gate type.
‫So this is the type of gate that the intercept is treated as.
‫So you can have things like interrupt gates, you can have trap gates and so on.
‫Will explain more about that as we go further in this lecture.
‫So here we have unus bits in the structure and then we have our selector.
‫Now this is the selector this instrument is bound to.
‫So for example, the COL code selector, right.
‫If someone calls an interrupt and this is set and this selector is set to the COL code selector, then
‫we will immediately begin executing on the COL code selector.
‫If we set something else, kernel data selector, then we can execute on the kernel data selector.
‫Ideally this will always be the kernel code selector.
‫OK, now finally we have the lower part of the offset to execute so bits zero to 15 of the function,
‫the function that we wish to execute.
‫So if you remember in real mode, we use segmented offset in the interrupt vector table to point to
‫the routine we wanted to run.
‫When someone calls that interrupt while these while this offset the lower the lower part of this offset
‫and the upper part, this offset, make up that function.
‫OK, this is how it's done in protected mode.
‫So this is how you could define this structure in C and you'll notice attribute packed by here.
‫This is incredibly important because the C compiler is going to try and align this structure here.
‫Right.
‫And it could potentially move variables in the wrong place.
‫And by ensuring we do actually attribute pact here, it keeps it as it is.
‫If you don't do this, you could run into issues, guys.
‫OK, so now let's explain what the gate types are.
‫So you have a 32 bit task and what the task.
‫Does is it references the test descriptors and it can help assist in multitasking when exceptions occur?
‫However, you don't need to worry about any of that stuff right now.
‫We now have a 16 bit interest gate, so interest rates are to be used.
‫Interrupts that.
‫We want to invoke ourselves in our code.
‫We can also use them for exceptions.
‫I tend to use rates for everything because it's just easier to work with, in my opinion.
‫However, we do have these different gates to choose from if we if we chose to do it.
‫So essentially the interest rate, simply put it is just for normal interrupts.
‫And if there's an exception, it can also be dealt with as an interest rate.
‫That's no problem.
‫So here we have the trap gate now.
‫So trap gates, the Lycanthrope gates, however they use for exceptions, we don't have to use them
‫for exceptions.
‫As I've just said, they basically disable entrance on entry and re-enable them when we call IRAT,
‫you know, return from interrupt instruction.
‫So here we have a 32 bit gate and a 32 trap gate.
‫I don't need to explain myself again because this is just the 32 bit equivalent of the gate.
‫Essentially, we will be using the 32 bit inch gate throughout most of this course.
‫So the descriptors, makeup and descriptor array or I should say, and skip the table.
‫So essentially it's just an array, basically.
‫So if we store an encrypted script in indexer of this array, what you think that represents interest
‫zero?
‫Of course, we store an index, one of the array.
‫What does it represent in CHIP one?
‫So, for example, if we want an end script to be bound to intercept three, then we simply put it in
‫zero one to three index three in the array.
‫So the ID is essentially a structure that points to our script to table and also specifies the size.
‫So we store the length of the script, a table minus one in the actual limit variable.
‫And our base here is an address to the script to table.
‫So calculate the limit is very easy.
‫You basically just get the size of the table.
‫I'm minus one from it.
‫Again, notice how we use at PREPACKED.
‫I recommend always using actually packed for sensitive structures that cannot be changed at the memory
‫level for risk of corrupting information.
‫Always use as we packed in these situations.
‫So how do we load the script?
‫The table is very simple.
‫We call the allied instruction and we simply pass in a pointer to the ID tr which will then load our
‫script to table.
‫So some final notes.
‫Then we can load the scripts table where we like in memory.
‫The scripts tables are clearly set up differently than the of vector table.
‫And one important note, during an interim, certain properties can get pushed to the stack and the
‫rules for this are quite complicated.
‫So I'm not going to explain them in one lecture.
‫We'll explain them as as we face them throughout the course.
‫However, if you're really interested, then you can search for X eighty-six IMT instruction and it
‫will show you a decision table along with some pseudocode of how that is calculated and when the processor
‫decides to do certain things and when the processor also decides not to do certain things.
‫So it explains all of that.
‫If you want to look that up.
‫However, to avoid baffling you, I will explain this as we go along the course.