Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22248

Cannot read sectors from disk in C

$
0
0

I'm using an i686-elf-gcc cross compiler to generate code to run in real-mode.

I'm trying to read a sector from my kernel. I know this is the location where my kernel is located, in the second sector, 0th drive, 0th track. It builds fine, but after I call read, sectors_read is still 0.

u8 status;u8 sectors_read;read(1, 0, 1, 0, 0, status, sectors_read);kprint("STATUS: ");hex_to_ascii(status, num_str_buffer);kprint(num_str_buffer);kprint("\nSECTORS READ: ");num_str_buffer[0] = '\0';hex_to_ascii(sectors_read, num_str_buffer);kprint(num_str_buffer);
void read(u8 sector_size, u8 track, u8 sector, u8 head, u8 drive, u8 status, u8 sectors_read){    asm volatile("mov $2, %AH");    asm volatile("mov %0, %%AL" : : "r"(sector_size) : );    asm volatile("mov %0, %%CH" : : "r"(track) : );    asm volatile("mov %0, %%CL" : : "r"(sector) : );    asm volatile("mov %0, %%DH" : : "r"(head));    asm volatile("mov %0, %%DL" : : "r"(drive));    asm volatile("int $0x13");    asm volatile("mov %%AH, %0":"=r"(status) : );    asm volatile("mov %%AL, %0":"=r"(sectors_read) : );}

Viewing all articles
Browse latest Browse all 22248

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>