parport(3hal)

✨ parport(3hal) ✨ β€” it's giving HAL, bestie πŸ’…

okay so bestie, gather round, because we're talking about hal_parport β€” portable access to PC-style parallel ports. yes, THOSE parallel ports. the chunky ones. iconic. πŸ”₯


🌸 NAME 🌸

hal_parport β€” portable access to PC-style parallel ports 🫢


πŸŽ€ SYNTAX πŸŽ€

like, here's the whole vibe:

#include "hal_parport.h"

int hal_parport_get(int comp_id, hal_parport_t *port, unsigned short
       base, unsigned short base_hi, unsigned int modes)

void hal_parport_release(hal_parport_t *port)

πŸ’– ARGUMENTS πŸ’–

  • comp_id β€” a HAL component identifier that you got back from an earlier call to hal_init. it's literally the receipts from that call, keep it safe bestie 🧾
  • port β€” a pointer to a hal_parport_t structure. just a lil struct pointer, no biggie ✨
  • base β€” the base address of the port (when port >= 16), or the linux port number of the port (when port < 16). yes, it switches meaning depending on the value, iykyk 😭
  • base_hi β€” the "high" address of the port, aka where the ECP registers live. pass 0 to use a probed high address, or -1 to disable the high address entirely. choose ur fighter πŸ’…
  • modes β€” this one advises the driver of the desired port modes, straight from <linux/parport.h>. and here's the tea: if a linux-detected port doesn't provide the requested modes, a warning gets printed with rtapi_print_msg. it does not make the port request fail though β€” because unfortunately, so many systems out there have EPP parports that genuinely work and linux just... doesn't detect them as such. not linux's finest moment fr πŸ™ˆ

πŸ¦‹ DESCRIPTION πŸ¦‹

hal_parport_get allocates a parallel port for the exclusive use of the named HAL component. exclusive, okay? main character energy only πŸ‘‘

the port must be released with hal_parport_release before the component exits with hal_exit. don't leave it hanging, bestie, that's rude 😀

🌈 HIGH ADDRESS PROBING 🌈

okay so here's how the high address gets figured out, step by step:

  • if the port is a parallel port known to Linux, and Linux detected a high I/O address, then that value is used. slay, thanks linux πŸ’–
  • otherwise, if base+0x400 is not registered to any device, that one gets used. cute ✨
  • otherwise, no address is used. shrug πŸ’€

and if no high address is detected at all, then port->base_hi is 0. noted πŸ“


πŸ’œ PARPORT STRUCTURE πŸ’œ

the whole thing looks like this:

typedef struct
{
    unsigned short base;
    unsigned short base_hi;
    .... // and further unspecified fields
} hal_parport_t;

yes there's a .... in there, that's the mystery fields, we don't talk about them 🀫


⭐ RETURN VALUE ⭐

hal_parport_get returns a HAL status code. on success, port gets filled out with all the info about the allocated port. on failure, the contents of port are undefined β€” except that it is safe (but not required) to pass this port to hal_parport_release. so like, you can hand it over to get cleaned up, you just don't have to 🫢

hal_parport_release doesn't return a value. it always succeeds. always. no notes, it just ate πŸ’…


πŸ“ NOTES πŸ“

in new code, prefer use of rtapi_parport to hal_parport. that's the glow-up, bestie 🌟


okay that's the whole page!! this was written up by the LinuxCNC Documentation girlies, dated 2006-10-12, and it lives in section parport(3hal). mwah, go forth and parallel-port responsibly πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈ