You need to make a driver to work with LBA ...

I did everything I needed, but I can’t understand, is it possible (I can) use an array (from C) as a segment in an assembler? The whole thing is that you need to pass a pointer to the model segment: register.

Here is an example code from my sys_writeLBA function:

 int sys_writeLBA(LBA info){ byte func = LBA_FS_WRITE; int32 jsbits = info.dap.sector << (8*4); int32 ssbits = info.dap.sector; asm volatile("pushal"); // push to stack all x32 regs /////////////////////////////////////////////////////////////////// // подготавливаем данные для вызова прерывания LBA asm volatile( "push %%es\n" "push %%bx" ); // сохраняем es и bx // используем buf, как сегмент, а оффсет - 0 asm( "movl (%0),%%es" // помещаем в es наш указатель на начало буфера : : "m" (info.dap.buf) : ); asm( "movl $0,%%bx" // здесь 0 так как смещение в буфере 0 ); /////////////////////////////////////////////////////////////////// // теперь нужно положить все данные в стек asm( "push %0\n" : : "r" (ssbits) : ); // кладём старшие биты номера сектора asm( "push %0\n" : : "r" (jsbits) : ); // младшие биты номера сектора asm("push %%es"); // сегмент asm("push %%bx"); // смещение в буфере asm("push $%0": : "M" (info.dap.sector_count) : ); asm("push $0x10"); // размер структуры DAP /////////////////////////////////////////////////////////////////// asm("movl $%0,%%ah" : : "M" (func) : ); // номер функции ( чтение ) asm("movl $%0,%%dl" : : "M" (info.hdrive) : ); // номер диска ( с нуля ) asm("movl %%esp,%%esi"); // устанавливаем указатель на структуру DAP ////////////////////////////////////////////////////////////////// asm("int $0x13"); // вызываем LBA ////////////////////////////////////////////////////////////////// // recovery used registers and clear stack // ... asm volatile("popal"); // pop from stack all x32 regs /////////////////////////////////////////////////////////////////// } 

about approximate work of LBA read on Habré ...

  • a bit of code to the question would not hurt ... - Fat-Zer 5:48 pm
  • um ... it's still not very clear what the question is ... for starters, is everything happening in real or protected mode? What is the length of the address? What memory model does the C code run / compile? - Fat-Zer
  • What do you mean by a memory model? - Fedor Lapshin
  • I meant that the generic code is compiled into a binary, which is designed to work in a flat address space, i.e., as usual, the pointers are 16/32/64-bit address without a segment or maybe the compiler has some then the built-in support for distant pointers on the segment model (it is unlikely today and there is no EMNIP in gcc, but it’s worth clarifying) ... - Fat-Zer
  • I was just trying to figure out how to find the address (in the segment shift format) on the array, to write segments there!? - Fedor Lapshin

0