In / out assembly instructions and devices

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
AlexHully
Member
Member
Posts: 62
Joined: Mon Jul 20, 2015 3:32 pm

In / out assembly instructions and devices

Post by AlexHully »

Hi,

I am not sure about a thing.
Say I have a sata hdd, a ssd, a usb key, a pci-e graphic card, a usb keyboard and a x86_64 architecture.

Apparently, the devices are all memory mapped.

So, is it correct to assume that I will never use in/out instructions on hardware 2011+ old (except on boot with the a20 gate and other legacy things)?

Bye
onlyonemac
Member
Member
Posts: 1146
Joined: Sat Mar 01, 2014 2:59 pm

Re: In / out assembly instructions and devices

Post by onlyonemac »

I believe that that is true, yes. But remember that you will need to write a driver; there is no simple way to do input and output via e.g. pci devices.
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
User avatar
SpyderTL
Member
Member
Posts: 1074
Joined: Sun Sep 19, 2010 10:05 pm

Re: In / out assembly instructions and devices

Post by SpyderTL »

I wouldn't go that far. I'd be suprised if you can build a whole kernel with no in/out instructions. I think OHCI USB controllers are I/O based, at least partially, so avoiding it entirely may be out of the question.
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
AlexHully
Member
Member
Posts: 62
Joined: Mon Jul 20, 2015 3:32 pm

Re: In / out assembly instructions and devices

Post by AlexHully »

I really like to ask extreme questions :D

So, how may I know if and when I need those instructions?

Rule of thumb or something?
Octocontrabass
Member
Member
Posts: 5588
Joined: Mon Mar 25, 2013 7:01 pm

Re: In / out assembly instructions and devices

Post by Octocontrabass »

The hardware documentation will tell you when you need to use port-mapped I/O.
User avatar
SpyderTL
Member
Member
Posts: 1074
Joined: Sun Sep 19, 2010 10:05 pm

Re: In / out assembly instructions and devices

Post by SpyderTL »

In most cases, a flag in the PCI device's configuration space determines if the device uses memory addresses or I/O addresses.
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
AlexHully
Member
Member
Posts: 62
Joined: Mon Jul 20, 2015 3:32 pm

Re: In / out assembly instructions and devices

Post by AlexHully »

Great,

Thanks !
User avatar
iansjack
Member
Member
Posts: 4707
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: In / out assembly instructions and devices

Post by iansjack »

Unless everything is PCI-e you will still need to use I/O ports.
jnc100
Member
Member
Posts: 775
Joined: Mon Apr 09, 2007 12:10 pm
Location: London, UK
Contact:

Re: In / out assembly instructions and devices

Post by jnc100 »

As far as I recall the ACPI SMI_CMD port can only be an IO port, thus you'd need at least one out instruction to switch to ACPI mode.

Regards,
John.
User avatar
BrightLight
Member
Member
Posts: 901
Joined: Sat Dec 27, 2014 9:11 am
Location: Maadi, Cairo, Egypt
Contact:

Re: In / out assembly instructions and devices

Post by BrightLight »

Some DMA and NICs are based on I/O ports. ACPI is based on I/O ports. You will still need them in your kernel, even if they are rarely used.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
Post Reply