Most active commenters

    ←back to thread

    309 points LorenDB | 11 comments | | HN request time: 0.413s | source | bottom
    1. 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 #
    2. ◴[] No.42636995[source]
    3. baq ◴[] No.42637011[source]
    the next one is somehow worse
    replies(1): >>42637550 #
    4. imperialdrive ◴[] No.42637087[source]
    Very curious what that would represent, to a layman.
    replies(1): >>42637273 #
    5. _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 #
    6. yjftsjthsd-h ◴[] No.42637550[source]
    Stuffing bytes through a faux serial port with rate limiting, or mangling the result into text? Those actually bother me less; they're kinda ugly, but in my mind they don't compare to cutting through all the nice abstractions and shoving raw bytes down a hardware port on a running Linux system.
    7. sedatk ◴[] No.42637707{3}[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 #
    8. buryat ◴[] No.42638478[source]
    I’m definitely running it unsupervised and without understanding what it does
    9. lpribis ◴[] No.42639538{4}[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 #
    10. skissane ◴[] No.42641222{5}[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 #
    11. hakfoo ◴[] No.42641768{6}[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.