kern

diff src/ata.c @ 88:a398bf73fe93

- added the partition table parsing code - starting with the filesystem
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 08 Dec 2011 13:34:47 +0200
parents 178d5a95e6de
children 2f555c81ae67
line diff
     1.1 --- a/src/ata.c	Wed Dec 07 17:10:37 2011 +0200
     1.2 +++ b/src/ata.c	Thu Dec 08 13:34:47 2011 +0200
     1.3 @@ -78,8 +78,7 @@
     1.4  #define MAX_IFACES		2
     1.5  #define MAX_DEV			(MAX_IFACES * 2)
     1.6  static struct device devices[MAX_DEV];
     1.7 -
     1.8 -static int use_irq;
     1.9 +static int ndev;
    1.10  
    1.11  /* This serves as a sync point for I/O. While the mutex is held,
    1.12   * some process is doing I/O and all the others must wait.
    1.13 @@ -93,28 +92,32 @@
    1.14  
    1.15  	interrupt(IRQ_TO_INTR(15), ata_intr);
    1.16  
    1.17 +	ndev = 0;
    1.18  	for(i=0; i<MAX_DEV; i++) {
    1.19  		int iface = i / MAX_IFACES;
    1.20  		int id = i % MAX_IFACES;
    1.21  
    1.22 -		if(identify(devices + i, iface, id) == -1) {
    1.23 -			devices[i].id = -1;
    1.24 +		if(identify(devices + ndev, iface, id) == 0) {
    1.25 +			ndev++;
    1.26  		}
    1.27  	}
    1.28 +}
    1.29  
    1.30 -	/* init code done, from now on use the irq sleep/wakeup mechanism */
    1.31 -	use_irq = 1;
    1.32 +int ata_num_devices(void)
    1.33 +{
    1.34 +	return ndev;
    1.35  }
    1.36  
    1.37  int ata_read_pio(int devno, uint64_t sect, void *buf)
    1.38  {
    1.39 -	int cmd, st, res = -1;
    1.40 +	int use_irq, cmd, st, res = -1;
    1.41  	uint32_t sect_low, sect_high;
    1.42  	struct device *dev = devices + devno;
    1.43  
    1.44  	if(dev->id == -1) {
    1.45  		return -1;
    1.46  	}
    1.47 +	use_irq = get_current_proc() != 0;
    1.48  
    1.49  	if(use_irq) {
    1.50  		/* wait for the interface to become available */