61 step by step to write the operating system task status segment TSS

I / O bitmap is located in the TSS, which may exist or may not exist, it is only used to set up access to specific ports, and without it will default to block all ports. It is because it may be available, so the TSS TSS segment limit limit (i.e., the actual size of -1) is not fixed. When the TSS does not include the I / O bitmap, TSS only 104 bytes in size. Having said that, when executed some IO instruction, if the current privilege level lower than IOPL, the processor will think that perhaps only to the current task alone allowed to go to certain ports, so it is to find the TSS I / O bits FIG, if the I / O bitmap does not exist, i.e., prohibit access to all ports, then the processor will throw an exception.

Read here, there are two problems to solve:

  1. The processor where to find the TSS I / O bitmap it?
  2. How to prove I / O bitmap does not exist?

In the TSS structure, there is an "I / O bitmap in the TSS offset address", it is offset 102 bytes in the TSS in place, the space occupies 2 bytes, is the upper left corner of FIG. 5-47 here it is used to store I / O bitmap offset address, i.e., this address is the I / O bitmap in the TSS in a 0 offset. If the presence of a TSS I / O bitmap, then, is used herein to preserve its offset schematically in FIG.

Illustrated, if there TSS I / O bitmap, then, would be located as shown in the top of the TSS, which is why the actual size of the TSS is not fixed, when including I / O bitmap, whose size is "I / O bitmap offset address "8192 + + 1 byte, 1 byte is the end of the I / O bitmap in the last 0xFF, long story, one will explain. Excluding the I / O bit map, the size of the smallest dimension compared with 104 bytes. Since the I / O bitmap offset is not fixed, it may be greater than equal to 104, the offset may be 102 bytes and a free area between the I / O bitmap in the TSS.

Look, since I / O bit map located in the TSS, then it must be the address of the TSS in the size range, i.e. the range of addresses is an offset between the TSS (104 ~ TSS segment limit limit), if the offset address is not in this range, i.e., greater than or equal TSS segment limit limit (TSS size -1), it means that no I / O bitmap.

Why now, at the end there 0xff IO bitmap.

In the computer system hardware, the IO port is addressed by byte, meaning that a port can write a byte of data. If a plurality of read ports successive bytes actually read collectively from the plurality of ports to the port number of the incoming starting. For example, such instructions may be read in 16-bit data port, i.e., a 2-byte read, assuming 16-bit port is a port 0x234:

in ax,0x234

This is equivalent to

in al,0x234
in ah,0x235

During read and write port, if the current privilege level CPL is lower than the privilege level of the IOPL IO, if I / O bit map, then the processor in the I / O port bit map is checked whether the bit corresponding to processor 0. If the read byte in a plurality of ports, a plurality of processors inevitably check bit corresponding to a plurality of ports in the successive I / O bitmap, the bit 0 must be allowed to have to access them.

A plurality of successive cross-bit byte may, for example the last one bit corresponding to the port 0x234 previous byte, 0x235 after a corresponding bit in byte 0 bit, so these must be word processor reading Festival are coming process.

Cross-byte no problem in most cases, but will be a problem when the last byte of a bit bitmap, the processor to read into multiple bytes, so the first two bit word where section on cross-border, and the byte does not belong to the scope of the bitmap.

To solve this problem, the last byte of a bitmap processor requirements must be 0xFF, this byte has two functions:

First, the processor allows I / O bitmap does not map all of the ports, i.e., I / O bitmap length may be less than 8KB, but the last byte of the bitmap must be 0xFF. If the bitmap outside the range of the port, the processor is disabled by default all access. As a result, if the last byte in the bitmap 0xFF belong to all 65,536 port range, we are all 1 byte represents all ports prohibit access to this byte represent, it did anything wrong.

Second, if the byte is beyond the scope of all ports, it is not used to map the port, is only used to "byte remainder" is the last byte of a bitmap as a cross boundary marks bitmap for . Avoid cross-border access memory outside of the TSS.

This is the last byte of the bitmap must be a reason of 0xFF.

You see I / O bitmap I said so busy, in fact, we do not have it, the full introduction here is to make everyone understand how IO access will only hurt.

To here, privileged to finish, and also the end of this chapter, Tips, I know this chapter a bit more, you have been very tired, we are now talking about closing, so you can skip Kanla not here.

Guess you like

Origin blog.csdn.net/sinolover/article/details/95201434