Calculating CHS for USB memory

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
ZigZogZang
Posts: 14
Joined: Tue Nov 26, 2013 7:41 am

Calculating CHS for USB memory

Post by ZigZogZang »

Hey,
I have problem with reading usb memory.
I have properly calculated data sector and now it's a moment where i suppose to use 0x13 (ah=0x02) interrupt for reading. Well while I was using code for floppy disk then it was normal to calculate CHS to get known head/sector/cylinder becouse of floppy's geometry and I have been using this kind of pattern to calculate it:

absolute sector = (logical sector mod sectors per track) + 1
absolute head = (logical sector / sectors per track) MOD number of heads
absolute track = logical sector / (sectors per track * number of heads)

I have found this code

https://github.com/ishanthilina/USB-FAT ... c/boot.asm

and this pdf file

https://github.com/ishanthilina/USB-FAT ... tation.pdf

and guy says to use it same way for usb memory but wtf ? ;) USB memory has sd card inside that hasn't cylinder etc, but a microcontroller inside it. So what for CHS is here and is int 13h (ah=0x02) correct interrupt to read usb memory ?
User avatar
wichtounet
Member
Member
Posts: 90
Joined: Fri Nov 01, 2013 4:05 pm
Location: Fribourg, Switzerland
Contact:

Re: Calculating CHS for USB memory

Post by wichtounet »

What about Extended Read Sectors From Drive (int 0x13 (ah = 0x42)) ?

With that you can read using LBA. This call does not support floppy.
Thor Operating System: C++ 64 bits OS: https://github.com/wichtounet/thor-os
Good osdeving!
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Calculating CHS for USB memory

Post by iansjack »

Set the geometry to what you want it to be.

http://www.damnsmalllinux.org/wiki/sett ... drive.html
ZigZogZang
Posts: 14
Joined: Tue Nov 26, 2013 7:41 am

Re: Calculating CHS for USB memory

Post by ZigZogZang »

wichtounet wrote:What about Extended Read Sectors From Drive (int 0x13 (ah = 0x42)) ?

With that you can read using LBA. This call does not support floppy.
Yea, but I don't understand ""USB-FAT32-BOOTLOADER" @ github project, what is it ? Guy who did it definitely use 0x13 (ah=0x02) interrupt for floppy and he is also calculating CHS. Why ? What for ?


One more question about 0x13 (ah=0x42) interrupt:
How about drive index (parameter for interrupt) ? How to get it for USB memory stick ?
iansjack wrote:Set the geometry to what you want it to be.

http://www.damnsmalllinux.org/wiki/sett ... drive.html
So use which one ? ah=0x02 or ah=0x42 ? What's difference ?
Post Reply