Where is the link from printf() to [txdata]?

(Les Marentette) #1

I quickly read through the Freedom Metal library.

I found the defines that point to the SFR’s inside the FE310 HiFive1 board specific file.

I’m trying to follow, how a libc -> stdio.h -> printf(“a”);
ultimately makes its way down to physical UART0 [txdata]

In the Freedom metal library, it seems that UART low level functions end at:
“extern inline int metal_uart_putc(struct metal_uart *uart, int c);”
" inline int metal_uart_putc(struct metal_uart *uart, int c) { return uart->vtable->putc(uart, c); }"

So, I don’t really get to see how each character gets pushed into [txdata]
I’m left assuming that there is some sort of interrupt driven code that checks for the next character after the last has been sent.

And since libc -> stdio.h doesn’t appear in the Freedom Metal library, I don’t know for sure how the higher level C function libc -> stdio -> printf() eventually makes its way down to the lower level metal functions.
Is there a special stdio that is compatible only with metal, or does metal some how intercept the standard libc -> stdio -> printf() flow?

Freedom Metal has a directory called ‘gloss’ and there is code there which looks like it’s intended to intercept system calls that libc -> stdio might normally be targeting at a host OS via syscalls, but I’m not sure, so I figure I’d ask the forum about this as well ?

I’d really like a map of all the function libraries and their interaction.
I’ve seen Rust, Metal, Gloss, Freedom e SDK, CLINT, CINT, is there a single page summary or extremely brief document that outlines the purpose and interaction of all the various SiFive code libraries ?
It feels like there is/was more than one way to get access to the hardware and now there is an effort to commonise on metal, am I seeing this right, or is there a newer, better supported way to access low level functions ?

Thank you,