Use of IN/OUT directive
Use of IN/OUT directive
deleted
Last edited by remy on Tue Oct 27, 2015 7:24 am, edited 2 times in total.
-
- Member
- Posts: 501
- Joined: Wed Jun 17, 2015 9:40 am
- Libera.chat IRC: glauxosdever
- Location: Athens, Greece
Re: Use of IN/OUT directive
Hi,
Regarding the code, you shouldn't send device specific commands in the bootloader, as you have BIOS services directly accessible. However, real mode is used for this. Only after you have done initializations, switch to Long Mode.
http://wiki.osdev.org/Rolling_Your_Own_Bootloader and http://wiki.osdev.org/My_Bootloader_Does_Not_Work might be of interest.
Regards,
glauxosdever
IN/OUT instructions are used to read and write to ports, to answer your question.remy wrote:I'm trying to make use of the IN/OUT directives.
Regarding the code, you shouldn't send device specific commands in the bootloader, as you have BIOS services directly accessible. However, real mode is used for this. Only after you have done initializations, switch to Long Mode.
http://wiki.osdev.org/Rolling_Your_Own_Bootloader and http://wiki.osdev.org/My_Bootloader_Does_Not_Work might be of interest.
Regards,
glauxosdever
- Schol-R-LEA
- Member
- Posts: 1925
- Joined: Fri Oct 27, 2006 9:42 am
- Location: Athens, GA, USA
Re: Use of IN/OUT directive
To elaborate a bit: there are a number of different ways for the CPU to pass data to and from the peripherals (basically, device outside of the CPU aside from the system memory). The most common one is memory mapping, where part of the main memory address space is redirected by the bus to registers or memory on the peripheral. A related technique is the somewhat misnamed Direct Memory Access, which is where a section of memory is mapped to a mediating device called a DMA controller, which can be triggered to transfer the whole block of memory to or from a device without requiring continued action by the CPU.
While PCs do use memory mapping, especially for video memory and peripheral firmware, and have DMA controllers for disks, the x86 family of processors also has a separate 'port' address space for input and output as well. The IN and OUT instructions (which are instructions with actual opcodes, not assembler directives) are used to access these ports. The original 8086/8088 design only allowed single bytes to be passed to the ports, but newer processors in the family allow for ports of two or four bytes to be addressed as well.
Port I/O is largely a thing of the past today, as most hardware now is memory mapped. It is really only used for the disk controllers, timers, old PS/2 style keyboard and mouse ports, and some parts of the legacy video management.
While PCs do use memory mapping, especially for video memory and peripheral firmware, and have DMA controllers for disks, the x86 family of processors also has a separate 'port' address space for input and output as well. The IN and OUT instructions (which are instructions with actual opcodes, not assembler directives) are used to access these ports. The original 8086/8088 design only allowed single bytes to be passed to the ports, but newer processors in the family allow for ports of two or four bytes to be addressed as well.
Port I/O is largely a thing of the past today, as most hardware now is memory mapped. It is really only used for the disk controllers, timers, old PS/2 style keyboard and mouse ports, and some parts of the legacy video management.
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Use of IN/OUT directive
I can see almost every error in the FAQ entry My Bootloader Does Not Work, in combination with a misleading thread title, huge code dump and minimal description of the actual problem. For everyone's sanity and the ability to help you properly this time and the next, could you please spend some time and read the forum rules as well? It would be much appreciated.