please help me professional programmers

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
swadallail
Posts: 10
Joined: Tue Feb 09, 2016 4:24 am
Libera.chat IRC: swad-al-lail

please help me professional programmers

Post by swadallail »

i am create bootloader use FAT32 and usb flash memory,
and i have kernel ,all that in 16-bits (real mode),
but i have one problem,
how and where put bootloader and kernel in flash memory ,
i am formatting flash memory by FAT32 and
i am convert bootloader and kernel from( .asm )to (.bin) please help me that is very important, see that image
NOTE:i am using os windows and virtuabox.
Attachments
osdev.JPG
User avatar
BrightLight
Member
Member
Posts: 901
Joined: Sat Dec 27, 2014 9:11 am
Location: Maadi, Cairo, Egypt
Contact:

Re: please help me professional programmers

Post by BrightLight »

I've tried my best to understand your question.
First, a FAT32 USB mass storage device is likely to be emulated as a hard disk by the BIOS (and thus have BIOS drive number 0x80, 0x81, etc...). Physical sector 0 of the mass storage device must have a valid MBR partition table. The BIOS will load and execute it at 0x0000:0x7C00 (some buggy BIOSes do 0x07C0:0x0000). This MBR will load the boot sector of the FAT32 partition and execute it at 0x0000:0x7C00. This boot sector will then parse the FAT32 file system to find your kernel image, load it and execute it.
Please correct me if I understood you wrong.
You know your OS is advanced when you stop using the Intel programming guide as a reference.
User avatar
osdever
Member
Member
Posts: 492
Joined: Fri Apr 03, 2015 9:41 am
Contact:

Re: please help me professional programmers

Post by osdever »

swadallail wrote:i am create bootloader use FAT32 and usb flash memory,
and i have kernel ,all that in 16-bits (real mode),
but i have one problem,
how and where put bootloader and kernel in flash memory ,
i am formatting flash memory by FAT32 and
i am convert bootloader and kernel from( .asm )to (.bin) please help me that is very important, see that image
NOTE:i am using os windows and virtuabox.
I can't normally understand you, but I'll try my best. You need to copy your compiled ASM code to first 512 bytes of your flash drive. I don't know how to do it on Windows, but in Linux it looks like that:

Code: Select all

sudo dd if=yourbin.bin of=/dev/sdb bs=1 count=512
Of course, you need to replace "sdb" with your device name.
Then your BIOS will place your MBR code on 0000:7c00h address in the RAM. Then you'll need to read a stage 2 of bootloader from flash drive, because 512 bytes is very small. Then you need to do

Code: Select all

jmp 0DEADBEEFh ; Replace DEADBEEFh with your stage 2 address. You're loaded it from your flash drive
Sorry if I mistaked, I always used GRUB.
Developing U365.
Source:
only testing: http://gitlab.com/bps-projs/U365/tree/testing

OSDev newbies can copy any code from my repositories, just leave a notice that this code was written by U365 development team, not by you.
shmx
Member
Member
Posts: 68
Joined: Sat Jan 16, 2016 10:43 am

Re: please help me professional programmers

Post by shmx »

Use DiskPart for create MBR.
I write my bootloader (on partition) using this code for Win:

Code: Select all

    HANDLE hFile;
    DWORD bytesread;
    char data[512];
    FILE *f;
    hFile = CreateFile("\\\.\\G:", GENERIC_WRITE, FILE_SHARE_WRITE, //G drive for example
			NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
			NULL);
    f = fopen("boot", "rb");
    while(!feof(f))
    {
        fread(data, 512, 1, f);
        if(!WriteFile(hFile, data, 512, &bytesread, NULL))
                return FALSE;
    }
    fclose(f);
    CloseHandle(hFile);
    return TRUE;
You can use a third-party utility for writing the boot sector.
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Re: please help me professional programmers

Post by Brynet-Inc »

Please don't send me private messages asking for help. I can only assume you sent them to other people as well.
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
Schol-R-LEA
Member
Member
Posts: 1925
Joined: Fri Oct 27, 2006 9:42 am
Location: Athens, GA, USA

Re: please help me professional programmers

Post by Schol-R-LEA »

Brynet-Inc wrote:Please don't send me private messages asking for help. I can only assume you sent them to other people as well.
This is indeed the case.

@swadallail: While I have no problem with getting PM questions myself, it is not a good idea to send the same question as a PM to several people rather than posting to the forum, for a few reasons. The most important of these is that it restricts the cross-communication - you can get several people saying the same thing, or you could get answers which other posters could help clarify or even dispute as inaccurate.

Also, it is considered mildly rude to PM someone you haven't already been in contact with. Private mail is intended to be just that - private. Unless you are addressing a specific individual about something others might not know about (i.e., a question about their particular code) and which is unlikely to be of interest to others, you are better off asking your questions on the forum instead of by PM.

Also, while I can understand that waiting for answers (and having to clarify your questions when you do get a reply) can be frustrating, you have to remember that (unlike IM, SMS, or chat rooms) a message board like this one is asynchronous - it may take a day, or even a week or more, to get an answer; furthermore, not all questions can be answered meaningfully, at least not without more details. You can usually expect someone to reply after a day or two, but often the reply will be a request for clarification or more information, especially if English is not your native tongue - technical discussions are difficult enough even when there is no language barrier, so it is worth taking extra time to be as clear as you can when asking one in an unfamiliar language.

If you haven't done so already, I recommend reading the How To Ask Questions wiki page, and How To Ask Questions The Smart Way as well, for advice on how to ask questions more effectively.

As for the question itself, the answers that omarrx024, shmx, and catnikita255 should be a starting place for you to solve the problem. If you need further advice, let us know.
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.
User avatar
SpyderTL
Member
Member
Posts: 1074
Joined: Sun Sep 19, 2010 10:05 pm

Re: please help me professional programmers

Post by SpyderTL »

swadallail wrote:i am create bootloader use FAT32 and usb flash memory,
and i have kernel ,all that in 16-bits (real mode),
but i have one problem,
how and where put bootloader and kernel in flash memory ,
i am formatting flash memory by FAT32 and
i am convert bootloader and kernel from( .asm )to (.bin) please help me that is very important, see that image
NOTE:i am using os windows and virtuabox.
If you only have two "files" to load into memory, you don't need a file system.

You can simply write both files to a single file, and then use that file as a USB Hard Drive image in VirtualBox.

Just make sure that the second "file" starts at 512 bytes in your new file, and you can safely assume that your second file can be loaded into memory by having the BIOS read logical block 1 (the second block), because hard drive blocks are almost universally 512 bytes long.

You can read about BIOS calls on the wiki page here: BIOS
Project: OZone
Source: GitHub
Current Task: LIB/OBJ file support
"The more they overthink the plumbing, the easier it is to stop up the drain." - Montgomery Scott
Post Reply