Re: uACPI, a portable and easy-to-integrate ACPI implementation
Posted: Fri May 09, 2025 3:26 pm
PRs are a thing, upstreaming compiler support is always welcome as long as it doesn't break existing code.
The Place to Start for Operating System Developers
http://forum.osdev.org/
PRs are a thing, upstreaming compiler support is always welcome as long as it doesn't break existing code.
To be completely honest, "portable code" does not mean it has to rot on a decade old C standard. You should probably just switch to a competent compiler...
There is no competent (or not) compiler that supports the 32-bit compact memory model other than Open Watcom, so this is simply not a solution. I might use uACPI as a service, running in a flat memory model, but the problem then is that all APIs are register based, and GCC use some very ancient standard for both inline assembly and defining register calling conventions. And even if I migrated those, it is not possible to create a decent libc for GCC that can be integrated into the project. Newlib is not good enough either since its multithreading interface is horrible. RDOS is very well integrated into Watcom, both for device drivers and applications.
It's easily implemented and useful for the more easily confused kind of programmer such as myself. Whether that's a good thing overall, I leave as a question for the ages. I've grown tired of defending my corner.
I think it is an easily defended corner.eekee wrote: ↑Sat May 10, 2025 5:04 amIt's easily implemented and useful for the more easily confused kind of programmer such as myself. Whether that's a good thing overall, I leave as a question for the ages. I've grown tired of defending my corner.
I do not understand that part. No data can encode bits, rather, bits encode data. But my point is another one.thewrongchristian wrote: ↑Sat May 10, 2025 5:36 am Some data simply encode bits, and it seems perfectly reasonable to define that data in terms of the data it's representing. Ie. binary data constants.
I have seen one too many 64-bit binary literals to even entertain the idea of binary literals. For small numbers, it is probably fine, although then the effort to convert it from hex is not too great, but long strings of bits are simply overwhelming me. And hexadecimal has the advantage of both simply being an abbreviation of binary (4 bits per digit) and lining up with byte boundaries. This compresses the information to a useful length and more easily allows the reader to understand the code. And fundamentally, readability matters a lot more than writability. See Perl for a refresher on that particular lesson.thewrongchristian wrote: ↑Sat May 10, 2025 5:36 am That you can represent such data in hex, decimal or octal is neither here nor there, and it is intellectual snobbery to look down on the idea of representing binary data as such in source code.
Code: Select all
0b0000000011001111100110100000000000000000000000001111111111111111
Code: Select all
0x00cf9a000000ffff
I think an example that might be more reasonable is data to define some built in bitmap font, you can define the bit patterns in binary constants like:nullplan wrote: ↑Sat May 10, 2025 10:44 amI do not understand that part. No data can encode bits, rather, bits encode data. But my point is another one.thewrongchristian wrote: ↑Sat May 10, 2025 5:36 am Some data simply encode bits, and it seems perfectly reasonable to define that data in terms of the data it's representing. Ie. binary data constants.I have seen one too many 64-bit binary literals to even entertain the idea of binary literals. For small numbers, it is probably fine, although then the effort to convert it from hex is not too great, but long strings of bits are simply overwhelming me. And hexadecimal has the advantage of both simply being an abbreviation of binary (4 bits per digit) and lining up with byte boundaries. This compresses the information to a useful length and more easily allows the reader to understand the code. And fundamentally, readability matters a lot more than writability. See Perl for a refresher on that particular lesson.thewrongchristian wrote: ↑Sat May 10, 2025 5:36 am That you can represent such data in hex, decimal or octal is neither here nor there, and it is intellectual snobbery to look down on the idea of representing binary data as such in source code.
For example, you can write a GDT descriptor asCode: Select all
0b0000000011001111100110100000000000000000000000001111111111111111
Code: Select all
uint8_t bitmap[] = {
0b00000000,
0b00111100,
0b01000010,
0b01000010,
0b01111110,
0b01000010,
0b01000010,
0b00000000,
};
I've recently had a lesson in readbility from Forth, it's very fresh in my mind. Using hex for bitfields is not very readable for me. Perhaps it would be with practice, but after all these years of interest in low-level coding and digital electronics, I'm still not fluent; I don't immediately think of the bit pattern for every digit. I do for some, but not others.nullplan wrote: ↑Sat May 10, 2025 10:44 am I have seen one too many 64-bit binary literals to even entertain the idea of binary literals. For small numbers, it is probably fine, although then the effort to convert it from hex is not too great, but long strings of bits are simply overwhelming me. And hexadecimal has the advantage of both simply being an abbreviation of binary (4 bits per digit) and lining up with byte boundaries. This compresses the information to a useful length and more easily allows the reader to understand the code. And fundamentally, readability matters a lot more than writability. See Perl for a refresher on that particular lesson.
Code: Select all
0b0000000011001111100110100000000000000000000000001111111111111111
Code: Select all
// gdl- pDPsedwa limit_________ base=0
0b1100<<52 | 0b10011010<<40 | 0xf<<48 | 0xffff
Code: Select all
0b0000_0000__1_1_0_0__1111__1_00_1_1_0_1_0__0000_0000_0000_0000_0000_0000__1111_1111_1111_1111
Code: Select all
// basehi___ gdl- limithi pDPsedwa baselo_______________________ limitlo____________
0b0000_0000_1100_1111____10011010_0000_0000_0000_0000_0000_0000_1111_1111_1111_1111
// basehi g d l - limithi p dp s e d w a baselo limitlo
0b0000_0000__1_1_0_0__1111_____1_00_1_1_0_1_0__0000_0000_0000_0000_0000_0000__1111_1111_1111_1111
I just use IOPL for the time being, but it does indeed look like you would have to do refcounting if you want to have proper protections and stuff. I was also thinking about switching to the IO bitmap mechanism for drivers in my kernel, but I have too many things on my TODO list and haven't given it much thought yet.rdos wrote: ↑Fri May 16, 2025 8:54 am I also wonder a bit about IO ports. It's nice that the mapping function has a base & size, but I still wonder if this means I can use the IO permission bitmap in the TSS to selectively enable & disable access to IO ports? This would work if no overlapping IO maps are created, but if there is such a possibility, then there would be a need for reference counting.
I discovered that my IO bitmap only covered the first 0x400 ports, and most modern ports are higher than that, so I had to let those go to the kernel, since when ports outside the IO bitmap are accessed, this causes a protection fault. I might want to try to build a full IO permission bitmap for the main thread in the uACPI server.mishakov wrote: ↑Sun May 18, 2025 6:07 amI just use IOPL for the time being, but it does indeed look like you would have to do refcounting if you want to have proper protections and stuff. I was also thinking about switching to the IO bitmap mechanism for drivers in my kernel, but I have too many things on my TODO list and haven't given it much thought yet.rdos wrote: ↑Fri May 16, 2025 8:54 am I also wonder a bit about IO ports. It's nice that the mapping function has a base & size, but I still wonder if this means I can use the IO permission bitmap in the TSS to selectively enable & disable access to IO ports? This would work if no overlapping IO maps are created, but if there is such a possibility, then there would be a need for reference counting.