21 lines
		
	
	
		
			No EOL
		
	
	
		
			542 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			21 lines
		
	
	
		
			No EOL
		
	
	
		
			542 B
		
	
	
	
		
			C
		
	
	
	
	
	
#include "fat.h"
 | 
						|
#include "ata.h"
 | 
						|
#include "panic.h"
 | 
						|
 | 
						|
void load_fat() {
 | 
						|
  read_sectors(FAT_INFO->reserved_sectors, FAT_INFO->sectors_per_fat, FAT);
 | 
						|
}
 | 
						|
 | 
						|
uint16_t get_cluster(uint16_t n) {
 | 
						|
  uint32_t t = *(uint32_t *)(FAT + (n / 2) * 3);
 | 
						|
  return (n % 2 ? (t >> 12) : t) & 0xfff;
 | 
						|
}
 | 
						|
 | 
						|
void set_cluster(uint16_t n, uint16_t v) {
 | 
						|
  uint32_t *t = (uint32_t *)(FAT + (n / 2) * 3);
 | 
						|
  *t = (*t & (n % 2 ? 0xff000fff : 0xfffff000)) | (n % 2 ? v << 12 : v);
 | 
						|
}
 | 
						|
 | 
						|
uint16_t get_start_cluster(uint8_t *path) {
 | 
						|
  panic("Not implemented (get_start_cluster).");
 | 
						|
} |