That sounds like a simple question but the answer is very complex. I recommend you look at old technology that was more simple and easy to understand, and then start moving forward. Look at the S100 bus and how simple 8 bit microprocessors such as the Z80 and 6502 did IO.
https://en.wikipedia.org/wiki/S-100_bus
https://z80journal.wordpress.com/2015/10/07/z80-io-space/
Then with x86 PC age, look at the ISA bus first https://en.wikipedia.org/wiki/Industry_Standard_Architecture
and later on, the PCI bus (should I even mention Microchannel?) : https://en.wikipedia.org/wiki/Conventional_PCI
Another direction for computer IO might be to learn about the Raspberry Pi GPIO interface: https://learn.sparkfun.com/tutorials/raspberry-gpio/all
Get an 8 bit microcontroller dev board for a few bucks and learn how to control the peripherals. AVR are good and there is a lot of material online to learn from. Sorry I don't know any books.
I recommend CSAPP, even though I'm not sure it's what you want: https://csapp.cs.cmu.edu and Inside The Machine.
I'm surprised there's no mention of the classic Computer Organization and Design by Patterson and Hennessy. Combine that with a recent book on the Linux kernel (either the O'Reilly one or I think there's one from Addison-Wesley) or the BSD red book (design and implementation of 4.4 bsd I think it's called) and I think you'd have good coverage of the topic.
While not exactly what you have asked for, I once delivered a related session intended for software developers -- "How Does a Processor Execute My Code? And Why?!" If the slides for this would be of interest, reach out to me using contact information in my profile.
You should definitely checkout this book - http://www.buthowdoitknow.com/
It explains everything in layman's term.
I would buy a raspberry PI and start with that, or an Arduino.
There is a Arduino simulator (I have not used it, others told me about it) on Tickercad.
One of the best ways would be to build a computer yourself. For that I haven’t found anything better than ECS [1]. Please try to build your own extensions to ECS and don’t forget to burn your computer to FPGA.
Follow that up with Computer Systems A programmers perspective.[2]
My review of ECS [3]
[1] https://www.amazon.com/Elements-Computing-Systems-Building-P...
[2] https://www.amazon.com/Computer-Systems-Programmers-Perspect...
[3] https://www.amazon.com/gp/customer-reviews/RZ4ME4QH22JML/ref...