IRC channel logs
2020-04-26.log
back to list of logs
<terminatrix>yup damo22 she told me you was working on the acpica a couple of days ago <terminatrix>then this morning i read you when you wrote it was working :P <terminatrix>on the other side, i've not been able to run the system on vbox >.<, and i'm still installing it on qemu (it goes painstakingly slow) <damo22>terminatrix: try -M q35,accel=kvm <damo22>in qemu with kvm option it runs super fast <terminatrix>damo22, im on w10 >.< so i got no support for hyperv <damo22>why is a person interested in hurd running windows? <terminatrix>i would have to create a native partition on my desk and install lnx to run qemu properly <almuhs>damo22: It's great!! Has you got found APIC tables then? <damo22>there is a function now called acpi_init() and you can put anything you need in there <damo22>it currently just loads all the tables <damo22>and populates internal structures <damo22>you could store the lapic address in a global stored in acpi_init.c <damo22>i could probably clean up the code by moving the "os layer" stuff to a new file ***Server sets mode: +nt
***Server sets mode: +nt
<almuhs>if this works, the next step is to parse the APIC table to find Local APIC, IOAPIC, and the common reference to Local APIC <damo22>i think theres a function for that <almuhs>AcpiGetTable(), if I remember well <damo22>i think it already called all that <damo22>its stored in initial_tables variable <almuhs>is lapic stored in initial tables? <damo22>i only called acpi_initialize_tables <damo22>i think i need to call a few other things before and after <almuhs>It's strange. The functions described in acpica-reference, doesn't appears in your acpica code <almuhs>mmm... maybe these appears, but with other naming <almuhs>but in the code, this appears as acpi_get_table(char *signature ... <damo22>yeah i used the linuxized version <almuhs>in your repository? or have you sent a new patch to upstream gnumach? <damo22>i need to implement 3 more stubs hang on <almuhs>I have to find how to compile acpica code in linux <almuhs>to test how to get APIC table, and how to parse It <almuhs>the acpica really is compiled and installed, but I need to learn how to use It. At first, what library I have to include in my C snippet <damo22>there is a way to compile it in userspace <damo22>i dont know exactly but you have to create a lib <damo22>trying to follow the init instructions in the spec <almuhs>be sure that you're calling the function after paging is configured. In other case, you will have addressing problems <damo22>+ acpi_initialize_tables (initial_tables, ACPI_MAX_TABLES, 0); <damo22>+ acpi_enable_subsystem (ACPI_FULL_INITIALIZATION); <damo22>+ acpi_initialize_objects (ACPI_FULL_INITIALIZATION); <almuhs>ok, then this is called just after start the system <almuhs>setup_main() -> machine_init() -> acpi_init() <almuhs>i386at_init() -> setup_main() -> machine_init() -> acpi_init() <almuhs>** c_boot_entry() -> setup_main() -> machine_init() -> acpi_init() <almuhs>and c_boot_entry() is called in the first routine, boothdr.S <almuhs>but, anyway, with this sequence, acpi_init() is called after all the memory was configured <almuhs>in the last function which is called before boot the rest of the system <damo22>ah it tried to create a semaphore <almuhs>youpi recommended me many time ago to do a "big lock" if there are not any fragile resource <damo22>but you have to provide semaphore handlers <damo22>but i currently set them to noop <almuhs>richard recommended me to implement atomic operations <almuhs>but the most simple approach is using locks <damo22>i will make my code hang if there is a problem <almuhs>I prefer separate this code in a new function (maybe a static function, to avoid expose It outside) <damo22>its a dirty hack to make it work <damo22>because its late where you are i had to code it fast <almuhs>maybe can be necessary to reserve a memory page <damo22>i think its calling acpi_os_create_semaphore <damo22>because i dont know how to create one <almuhs>this? status = acpi_ut_mutex_initialize(); <damo22>ACPI Error: AE_NO_MEMORY, During Global Mutex creation (20200326/utxfinit-67) <almuhs>status = acpi_ut_mutex_initialize(); <damo22>"cant create semaphore" is in acpi_init.c <almuhs>I remember read anything about mutex in Mach, but I don't remember exactly where <almuhs>yes, but I watch utxfinit-67. This is the file and line <almuhs>but I don't know if It possible to call linux code from gnumach directly <almuhs>yes, but linux has Its own libraries <almuhs>and sometimes these can be in conflict with gnumach libraries <almuhs>in special, glibc-like libraries <almuhs>but I'm not sure about the linux semaphore can runs well in gnumach, outside of linux code <damo22>what is a semaphore in the context of this? <almuhs>a semaphore is a structure which controls the access to the same memory resource, setting a turn for each thread which wants to access it <damo22>does gnumach itself have semaphores? <almuhs>I think not, but I remember something similar <youpi>in gnumach you'd rather use a simple lock <almuhs>the semaphore implementation can be easy, but not trivial. It's necessary to control samelock <almuhs>(I don't remember the name exactly, but in concurrency techniques, It's possible that in some situations, all threads are block, waiting to another <terminatrix>yeah, it sounds like you have some sort of intelligent algorythm overseeing the whole sceneario <almuhs>there are many pseudocodes to implement a software semaphore, avoiding deadlocks <damo22>youpi: did you see my ACPICA stuff? <almuhs>youpi possibly are sleeping now. He is french <almuhs>by this reason, I told you yesterday that ask your question via maillist <almuhs>then you have to wait, or reply your own mail being more explicit <almuhs>oh, I've just saw that youpi replied you 2 hours ago <damo22>i solved that problem by adding infinite for loop when it fails <damo22>i will try to allocate a simple lock <almuhs>gnumach has Its own implementations of simple lock <damo22>yeah but it needs to have a name <almuhs>in sched_prim.c there are some examples, If I remembers well <damo22>acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_semaphore * handle) <almuhs>what says the docs about this function? <damo22>whats the difference between a spinlock and a semaphore <damo22>#define acpi_spinlock simple_lock_t <almuhs>this phrase is very descriptive: "A semaphore has a counter and will allow itself being acquired by one or several threads, depending on what value you post to it, and (in some implementations) depending on what its maximum allowable value is." <almuhs>this is the counter in your function <damo22>ok a spinlock is a semaphore with max value=1 <youpi>a mutex is a semaphore with max value <youpi>a spinlock is a mutex that spins instead of sleeping <youpi>(when having to wait for it to be ready) <almuhs>a spinlock is a waiting loop, is not? <damo22>do i need to implement semaphores in gnumach? <damo22>because simple_lock doesnt seem to be enough <youpi>does acpi really use semaphores as semaphores, and not just as locks ? <youpi>almuhs: it's a busy-waiting loop yes <youpi>i.E. keep retrying, instead of going to sleep <almuhs>the function prototype use a semaphore <almuhs><damo22> acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_semaphore * handle) <youpi>yes but that doesn't mean it is actually used with max_units > 1 <almuhs>we can find the calls to this function <damo22>status = acpi_os_create_semaphore(ACPI_NO_UNIT_LIMIT, 0, <almuhs>status = acpi_os_create_semaphore(1, 0, &main_thread_gate); <almuhs>status = acpi_os_create_semaphore(1, 1, &thread_complete_gate) <damo22>if you create a semaphore with 1, 1 doesnt that mean you can use a simple lock, and just lock it <youpi>to get inspiration for a semaphore implementation, you can see linux/dev/kernel/sched.c 's __down and __up <youpi>(1): not exactly indeed, but most often that's meant to be a lock, and thus simplelock is fine <youpi>but yeah, if there are real uses of real semaphores, then see sched.c <almuhs>I have academical notes about semaphores, but I don't know if this can be useful to this purpose <damo22>i could just do a simple lock and do a while loop? <damo22>i'll try to hack it and assume max_units == 1 <almuhs>but if max_units == 1, then this could crash with NCPUS > 2, is not? <youpi>max_units is completely unrelated to ncpus <almuhs>if NCPUS > 2, and more than two tries to access to same resource, this could crash <youpi>simple_lock does protect against any number of accessors <youpi>and max_unit in the semaphore definition is *not* the number of accessors <youpi>it's the number of tokens in the semaphore <damo22>linux/src/include/asm-i386/semaphore.h <youpi>the number of tokens, really <youpi>yes but that's awfully linux-glue-specific <youpi>and what you need is not only the fast-path of the inline <youpi>but the slow path that I mentioned above <youpi>fast path is to handle the common case when it's available <youpi>and if it's actually not available, you have to go the slow path <damo22>i will try to code this as a simple lock for now and assert if max_units > 1 <almuhs>if you needs, It's not difficult to find academical notes about semaphores, mutex... etc <almuhs>with this you can learn a theorical concept <almuhs>this comment in wikipedia page seems important: <almuhs>"If the implementation does not ensure atomicity of the increment, decrement and comparison operations, then there is a risk of increments or decrements being forgotten, or of the semaphore value becoming negative. Atomicity may be achieved by using a machine instruction that is able to read, modify and write the semaphore in a single operation" <damo22>i coded it as simple locks but it crashes on kmem_cache_alloc <almuhs>if you can find academical notes, or books about concurrency, you can understand better these concepts <damo22>its parsing the AML but getting stuck <damo22>does anyone know how kalloc / kfree is supposed to work <damo22>how are you supposed to free memory if you dont know the size <damo22>the linux/ memory allocator stores the kmallocs in a list <damo22>youpi: when i vfree an address mapped with vremap it crashes <damo22>i have no idea how to map physical addresses to virtual addresses and then free them <damo22>this is gnumach log with verbose acpi <damo22>looks like the size=0 of the AML i wonder if that caused it to cras <damo22>i think the DSDT on qemu is empty <damo22>youpi: braunr thinks we should not put acpica into the kernel, just put a minimal APIC table parser in there instead, but i think there is stuff in DSDT that needs to be parsed from AML and executed to complete the init of the board before the first timer interrupt <youpi>it'd be better not to put all interpreter stuff in there yes