←back to thread

309 points LorenDB | 5 comments | | HN request time: 0s | source
Show context
yjftsjthsd-h ◴[] No.42636808[source]
Well.

  doas dd seek=$((0x$1)) bs=1 count=1 of=/dev/port < <(xxd -p -r <<< "$2")
There's the horrors I came for;)
replies(4): >>42636995 #>>42637011 #>>42637087 #>>42638478 #
imperialdrive ◴[] No.42637087[source]
Very curious what that would represent, to a layman.
replies(1): >>42637273 #
1. _joel ◴[] No.42637273[source]
Seems it's seeking to the the first ($1) argument in /dev/port file and writing in stuff from the second argument ($2) with some hex/decimal magic. It's pretty hacky, but if it works, it works.
replies(1): >>42637707 #
2. sedatk ◴[] No.42637707[source]
Seek operation may be working like "function selection" on that specific device driver. The hex encoding of the seek offset gave me such vibes.
replies(1): >>42639538 #
3. lpribis ◴[] No.42639538[source]
Writing to seek ofset N of /dev/port puts the written byte out on port N. There are 256 possible IO ports in x86 which afaik can be mapped arbitrarily by manufacturers. The hex encoding (using bash math eval syntax) is just for their convenience, so they can write `./outb 80 X` instead of `./outb 0x80 X`, as dd takes decimal parameters, not hex.
replies(1): >>42641222 #
4. skissane ◴[] No.42641222{3}[source]
> There are 256 possible IO ports in x86

65,536 IO ports not 256. Not counting memory mapped IO ports whose number is only limited by the physical address space

> which afaik can be mapped arbitrarily by manufacturers

Pretty much, but some of the assignments IBM picked for the original IBM PC are a de facto standard. However, as newer machines lose more and more legacy peripherals and controllers, fewer and fewer of those original ports still exist. Thats said, the article mentions using the POST port (0x80) which is one of those original port numbers.

replies(1): >>42641768 #
5. hakfoo ◴[] No.42641768{4}[source]
While you can theoretically talk to 65,536 ports, a lot of old hardware only wired up the lowest 10 or so bits of the address space. So the parallel port at 0x378 might also be accessible at 0x1378, 2378... F378.