I typically don't like to just paste Wikipedia articles in a community. But this topic is so general that it's probably the best to read through it on wiki:
http://en.wikipedia.org/wiki/Input/output
If you want much more detailed information it probably makes sense to refer to
Modern Operating Systems (3rd Edition): Andrew S. Tanenbaum: 9780136006633: Amazon.com: Books
It includes very detailed information about how an operating system works.