simple bootsector beginner's problem

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.
djmauretto
Member
Member
Posts: 116
Joined: Wed Oct 22, 2008 2:21 am
Location: Roma,Italy

Re: simple bootsector beginner's problem

Post by djmauretto »

pompon wrote:my notebook ASUS F3Sseries
You have a bad notebook,
Do you know about Trusted Computing ?
pompon
Posts: 15
Joined: Fri Mar 13, 2009 11:04 am

Re: simple bootsector beginner's problem

Post by pompon »

Dex wrote:I would like to help, but first i need a problem, i tested your 2nd code on 8 differant PC's and it works on all of them.
Well, as I have written, on PC I obtained "Hello world", but key pressing doesn't cause loop to repeat. On laptop anything doesn't work. Again it's: ASUS F3Sseries, Intel Core 2 Duo T5550. Which other parameters can be important? I'll give them if possible.
JohnnyTheDon wrote:Did you use a long jump to make sure segments are set properly (as was suggested)? That would explain why it works on one computer but not another (bioses can load segments with whatever they want).
Yes, the first thing i'm doing is "ljmp 0x07c0:main". It actually changes the result (comparing to the 2nd code version) but, as I have written, I get only black screen.
djmauretto wrote: You have a bad notebook,
Do you know about Trusted Computing ?
I haven't knew about that untill now (but googling a bit made me feel quite uncomfortable :(). Is really problem so far that I can not boot from my own code :shock: ? Or is it a different suggestion?
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Re: simple bootsector beginner's problem

Post by Dex »

pompon wrote:
Dex wrote:I would like to help, but first i need a problem, i tested your 2nd code on 8 differant PC's and it works on all of them.
Well, as I have written, on PC I obtained "Hello world", but key pressing doesn't cause loop to repeat. On laptop anything doesn't work. Again it's: ASUS F3Sseries, Intel Core 2 Duo T5550. Which other parameters can be important? I'll give them if possible.
But using a floppy, on my test PC's it prints hello world then when you press a key it prints it again
hello world
hello world
hello world
hello world
So there could be a problem writing it to the fob, how are you doing this ?.
pompon
Posts: 15
Joined: Fri Mar 13, 2009 11:04 am

Re: simple bootsector beginner's problem

Post by pompon »

Dex wrote: So there could be a problem writing it to the fob, how are you doing this ?.
# nasm main.s -o main.bin
# sudo dd if=main.bin of=/dev/sdb bs=512 count=1
main.s - source code
sdb - flash disk
djmauretto
Member
Member
Posts: 116
Joined: Wed Oct 22, 2008 2:21 am
Location: Roma,Italy

Re: simple bootsector beginner's problem

Post by djmauretto »

First of all you must to have an Exadecimal Editor to verify
drive sector or copy to hand binary file to drive.
try to add Bios Parameter Block to your boot sector,
if your usb boot emulate floppy add this:

Code: Select all

	JMP	Start
	NOP

;======================
; Bios Parameter Block
;======================

OEM			DB "Pompon  "
Bytes_per_sector	DW 512		
Sectors_per_cluster	DB 1		
Reserved_sectors	DW 1		
Number_of_FATs		DB 2		
Root_entries		DW 224		
Total_sector_count	DW 2880			; 80*2*18		
Media_descriptor	DB 0F0H			; Floppy
Sectors_per_FAT		DW 9
Sectors_per_track	DW 18
Heads			DW 2
Hidden_sectors		DD 0
Total_sector_FAT32	DD 0			
BIOS_drive		DB 0
Unused			DB 0
Boot_signature		DB 29H				
Volume_ID		DD 0
Volume_label		DB "Boot Sector"
File_system_type	DB "FAT12   "

start:
; your boot code
djmauretto
Member
Member
Posts: 116
Joined: Wed Oct 22, 2008 2:21 am
Location: Roma,Italy

Re: simple bootsector beginner's problem

Post by djmauretto »

berkus wrote:I believe Exadecimal Editors were banned on this plane of existence as well as Loathing point calculations.</ot>
:?: :?: :?: :?:
I don't understand ,please rephrase your statment
pompon
Posts: 15
Joined: Fri Mar 13, 2009 11:04 am

Re: simple bootsector beginner's problem

Post by pompon »

YAHOOO!!! djmauretto, thank you very much! I added your code and it simply works :mrgreen: . Now, can you explain me what it actually does and why was it necessary? :D :D :D
Hyperdrive
Member
Member
Posts: 93
Joined: Mon Nov 24, 2008 9:13 am

Re: simple bootsector beginner's problem

Post by Hyperdrive »

pompon wrote:YAHOOO!!! djmauretto, thank you very much! I added your code and it simply works :mrgreen: . Now, can you explain me what it actually does and why was it necessary? :D :D :D
BIOSes emulate USB drives in different ways:

(1) Some BIOSes emulate USB drives as a floppy drive and looks for the BIOS Parameter Block (BPB). If it isn't present the BIOS refuses to load and execute the boot sector.

(2) Other BIOSes may emulate USB drives as a hard drive and they don't look for a BPB. So, when there's no BPB they don't care (and they also don't care if there is a BPB).

Your BIOS seems to work as (1). Because you had no BPB included in your boot sector the BIOS thought it wasn't valid and so didn't load/execute your code. Adding the BPB solved that.

--TS
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: simple bootsector beginner's problem

Post by Troy Martin »

djmauretto wrote:
berkus wrote:I believe Exadecimal Editors were banned on this plane of existence as well as Loathing point calculations.</ot>
:?: :?: :?: :?:
I don't understand ,please rephrase your statment
Ignore that post :P
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
djmauretto
Member
Member
Posts: 116
Joined: Wed Oct 22, 2008 2:21 am
Location: Roma,Italy

Re: simple bootsector beginner's problem

Post by djmauretto »

pompon wrote:YAHOOO!!! djmauretto, thank you very much! I added your code and it simply works :mrgreen: . Now, can you explain me what it actually does and why was it necessary? :D :D :D
OK ,I'm happy :D
Can you try TCG (Trusted computing group) BIOS function
to verify availability ?
You can use this BIOS function:

Code: Select all

mov  ax,0bb00h                  ; TCG_StatusCheck
int  1ah
test  eax,eax
jnz  TCG_Not_Present
cmp  ebx,41504354h		; 'TCPA' ?
jnz   TCG_Not_Present
add  cx,3030h                    ; CH = Major Version, CL,Minor Version 
call   Print_Version
After that you can hash your boot code with function 7
so it will be trusted :P
pompon
Posts: 15
Joined: Fri Mar 13, 2009 11:04 am

Re: simple bootsector beginner's problem

Post by pompon »

djmauretto wrote: Can you try TCG (Trusted computing group) BIOS function
to verify availability ?
You can use this BIOS function:

Code: Select all

mov  ax,0bb00h                  ; TCG_StatusCheck
int  1ah
test  eax,eax
jnz  TCG_Not_Present
cmp  ebx,41504354h		; 'TCPA' ?
jnz   TCG_Not_Present
add  cx,3030h                    ; CH = Major Version, CL,Minor Version 
call   Print_Version
After that you can hash your boot code with function 7
so it will be trusted :P
Well, I probably don't understand what do you want me to do... I'm working under ubuntu and as I tried to "int 1ah" I've received segfault. shall I try to execute your code from the boot sector? :|
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Re: simple bootsector beginner's problem

Post by Dex »

We did some test here: http://forum.osdev.org/viewtopic.php?f=1&t=19366
Ps: I tryed to tell you there was nothing wrong with the code.
djmauretto
Member
Member
Posts: 116
Joined: Wed Oct 22, 2008 2:21 am
Location: Roma,Italy

Re: simple bootsector beginner's problem

Post by djmauretto »

pompon wrote:Well, I probably don't understand what do you want me to do... I'm working under ubuntu and as I tried to "int 1ah" I've received segfault. shall I try to execute your code from the boot sector? :|
Yes from boot sector, note that Ubuntu terminal is 32bit not VM86,
anyway it's not important, i'm just curious
about TCG level of your BIOS..
about hash your boot sector so you can avoid that some alter it :-)
pompon
Posts: 15
Joined: Fri Mar 13, 2009 11:04 am

Re: simple bootsector beginner's problem

Post by pompon »

djmauretto wrote: Can you try TCG (Trusted computing group) BIOS function
to verify availability ?
Finally, I have tested it with your code and it seems that I don't have TCG.
Thank you once again,
Pompon
djmauretto
Member
Member
Posts: 116
Joined: Wed Oct 22, 2008 2:21 am
Location: Roma,Italy

Re: simple bootsector beginner's problem

Post by djmauretto »

pompon wrote:Finally, I have tested it with your code and it seems that I don't have TCG.
Thank you once again,
Pompon
Thank you for test :wink:
Anyway your Asus F3s has a TPM chip ,only his default status is disable 8)
Post Reply