ahci: handle blocking threads
This commit is contained in:
parent
2b7b3ae08e
commit
eeee9c1638
3 changed files with 12 additions and 5 deletions
10
dev/ahci.c
10
dev/ahci.c
|
|
@ -4,6 +4,7 @@
|
|||
#include <kernel/block.h>
|
||||
#include <kernel/irq.h>
|
||||
#include <kernel/pio.h>
|
||||
#include <kernel/proc.h>
|
||||
|
||||
#include <dev/ahci.h>
|
||||
#include <dev/pci.h>
|
||||
|
|
@ -206,13 +207,18 @@ bool ahci_access_sectors(struct sata_device *dev, paddr_t lba, uint16_t count, p
|
|||
port->ci = 1 << slot;
|
||||
|
||||
/* wait for completion */
|
||||
struct proc *proc = proc_find(getpid());
|
||||
while (1) {
|
||||
if ((port->ci & (1 << slot)) == 0)
|
||||
break;
|
||||
if (port->is & HBA_PORT_IS_TFES) {
|
||||
kprintf(LOG_ERROR "AHCI: Read disk error\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((port->ci & (1 << slot)) == 0)
|
||||
break;
|
||||
else if (proc->buddy_proc)
|
||||
sswtch();
|
||||
|
||||
}
|
||||
|
||||
/* check again */
|
||||
|
|
|
|||
|
|
@ -168,6 +168,9 @@ void kmain()
|
|||
uint16_t tss = gdt_insert_tss(ptr);
|
||||
ltr(tss);
|
||||
|
||||
pic_init();
|
||||
apic_init();
|
||||
|
||||
/* init the application processors */
|
||||
struct limine_smp_response *smp_resp = smp_req.response;
|
||||
proc_init(smp_resp->cpu_count);
|
||||
|
|
@ -188,9 +191,6 @@ void kmain()
|
|||
|
||||
devfs_init();
|
||||
|
||||
pic_init();
|
||||
apic_init();
|
||||
|
||||
sem_t *init_sem = sem_create(0);
|
||||
|
||||
for (unsigned i = 0; i < smp_resp->cpu_count; i++) {
|
||||
|
|
|
|||
|
|
@ -369,5 +369,6 @@ void proc_init(unsigned num_cpus)
|
|||
* this value is never actually used, it prevents other processes from
|
||||
* having PID 0
|
||||
*/
|
||||
proc_set_current(0);
|
||||
(void)rbt_insert(proc_tree, 0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue