Example #1
0
///////// TEST PROGRAM, NOT FOR ACTUAL USERS, MAKES DIRECT KERNEL CALLS !
int _dread(int argc, char** argv) {
	if(argc > 1)	{
		int i; 
		char msg[2048];
		for(i = 0; i < 2048; ++i)
		{
			msg[i] = 0;
		}

		unsigned int sector = 0;	

		sector = atoi(argv[1]);
		if(!sector)
		{
			sector = 1;
		}

		int offset            = 0;
		int count             = 1024;
		int ata               = ATA0;

		_disk_read(ata, msg, 1, sector);

		printf("Lei esto del sector %d\n", sector);
		i = 0;
		for(; i < count; ++i) {
			printf("%c", msg[i]);
		}
		printf("\n");
	}
}
Example #2
0
int _cache_read(int ata, char * ans, int numreads, unsigned int sector){
	int i = 0;
	int cached = 0;
	for( i=0; i<SECTORS; i++ ){
		if( sectors[i].used && sectors[i].index == sector ){
			cached = 1;
			int j = 0;
			for( j=0; j<SECTOR_SIZE; j++ ){
				ans[j] = sectors[i].data[j];
			}
		}
	}
	if( !cached ){
		i = getFree();
		sectors[i].index = sector;
		_disk_read( ata, sectors[i].data, 1, sector);
		sectors[i].used = 1;
		sectors[i].dirty = 0;
		int j = 0;
		for( j=0; j<SECTOR_SIZE; j++ ){
			ans[j] = sectors[i].data[j];
		}
	}
	if( numreads == 1 ){
		return 1;
	}
	
	return _cache_read( ata, ans + SECTOR_SIZE, numreads-1, sector+1);
}
Example #3
0
void hdd_read(char * answer, unsigned int sector) {
	if(cache){
		_cache_read(ATA0, answer, 2, sector);
	}
	else{
		_disk_read(ATA0, answer, 2, sector);
	}
}
Example #4
0
int read_disk(int ata, int sector, void * msg, int count, int lenght) {
	int ret = 0, base = 0;
	/*new cache stuff
	 if (!cache_isinarray(sector)) {
	 ret = _disk_read(0x1f0, (char*) msg, count / 512, sector + 1);
	 base = cache_getbase(0);
	 cache_insertblock(base, (char*) msg, count / 512);
	 printf("\ntest read cache\n");
	 cache_printblocks();
	 } else {
	 ret = _disk_read(0x1f0, (char*) msg, count / 512, sector + 1);
	return ret;
	 }*/

	//##################### NEW
	/*new cache stuff according to hipotetical_read*/
	/*int reads;
	int quantblocks = (int) (count / 512) + 1;
	//Si la cantidad de bloques supera a la de la cache entonces leo directamente de disco.
	if (quantblocks > CACHE_BLOCKS) {
		_disk_read(0x1f0,(char*)msg,count/512,sector+1);
		return -1; //disk_read(block,buffer,size);
	}
	//Si no estan todos los bloques juntos, entonces leo e inserto en al cache.
	if (cache_searchblockpackage(sector, quantblocks) == -1) {
		//reads = disk_read(block,buffer,size);
		cache_insertblock(sector, msg, quantblocks);
		//return reads;
	}

	return cache_read(sector, msg, count);

	//calculo la cantidad de bloques.
	//me fijo en la cache si estan todos los bloques.
	//si no esta leo y pongo todo en cache.
	//devuelvo lo que esta en la cache en el buffer

	//##################### NEW
*/
	return _disk_read(0x1f0,(char*)msg,count/512,sector+1);

}