Wanting to use the "hello world" bootloader code
Author |
Message |
Terry A. Davis
Joined: Tue Jan 19, 2010 11:51 pm Posts: 66
|
![Post Post](./styles/serenity/imageset/icon_topic_latest.gif) Re: Wanting to use the "hello world" bootloader code
This is the OSDev line and anything else is heresy: Quote: If I may give a few suggestions..
Start with a tutorial, like JamesM's kernel tutorials for OSDeving on a *nix environment(Cygwin works), or bkerndev for OSDeving on a Windows environment Then, after you finished the tutorial(IMHO I recommend JamesM's tutorial for being more expansive), you can build on it by adding things like:
A filesystem driver Dynamic driver loading The ability to run programs(which will most likely depend on a FS) A GUI, (although such a thing, IMHO, would be better suited for an external program) An improved TUI, with fonts Port a few programs, like GCC After that, I would test my OS by running it on bare hardware(Although I don't trust myself yet to do so )
My operating system started as an DOS application written in TASM in 1993. DOS runs in real mode and nothing stops you from switching to protected mode. I resurrected it in 2003 and ran it by installing FreeDOS to run both TASM and my operating system. I had some dreams for my OS -- I hated unix make files and scripting, so I wanted C/C++ for scripting. I did a grand unification and made my scripting the same as my programming language. Every operating system must do scripting -- basically it's writing an interpretor, right? Why not do it as C/C++, if you don't mind getting rid of pipes and the unix command line. I started without a filesystem, just source files embedded right in my kernel image as data which I compiled with my operating system like an AUTOEXEC.BAT script. So, I wrote an interpreted language and and assembler and soon was up-and-running with a completely self-contained system, where I could develop and test without ever leaving code I did not write myself. I converted my interpretor to a compiler and optimized it over the years. I added the FAT file system and learned a CRITICAL lesson you must all pay attention to: I discovered that by using a standard -- FAT -- I lost freedom to make something different. No longer could I dream of metadata or a custom syntax for file specifier masks like "~" being a character for NOT. The lesson is, the more standard things you bring-in, the less distinct your system will possibly be because your hands get tied. If you import GCC I guarantee you will soon to be forced to do everything the Linux way. Running GCC probably condemns you to writing an almost exact immitation of Linux and that is pointless! As for running on real hardware... the point in my mind was to write an operating system, not an application. An operating system running in VMWare or Bochs is not an operating system, but an application, if you know what I mean. Where is the glory of doing a true operating system. That'snot fun. If I have a choice of mine working on real hardware or working in an emulator, I want mine to work on real hardware.
|
Tue Mar 30, 2010 1:52 am |
|
![](./styles/serenity/theme/images/spacer.gif) |
Terry A. Davis
Joined: Tue Jan 19, 2010 11:51 pm Posts: 66
|
![Post Post](./styles/serenity/imageset/icon_topic_latest.gif) Re: Wanting to use the "hello world" bootloader code
Some sour grapes guy at osdev is saying PAE mode is just as good as 64-bit mode. Who does he think he's kidding! What kind of moron would believe that?
It turns-out 64-bit mode is a struggle for those who tackle it conventionally. I have one map for all tasks on all cores -- virtual identity-mapped to physical. It's dirt simple and awesome. I can call MAlloc(8*1024*1024*1024) and get a 8 Gig chunk of my 12 Gig of RAM. I don't think Windows or Linux can do that. I'm not sure. Maybe, Window's server, but they have huge legacy constraints.
The secret is I made my own tools -- compiler -- so I don't suffer from the grief that makes loser sour-grapes sorts of people. My compiler and loader will patch absolute addresses, so my programs don't have to go at a certain address. Come-on! It's not that hard to do a compiler.
Go to OSdev and look -- it's nothing but sour grapes losers criticizing 64-bit mode.
|
Tue Mar 30, 2010 4:48 am |
|
![](./styles/serenity/theme/images/spacer.gif) |
Terry A. Davis
Joined: Tue Jan 19, 2010 11:51 pm Posts: 66
|
![Post Post](./styles/serenity/imageset/icon_topic_latest.gif) Re: Wanting to use the "hello world" bootloader code
OSDev dude said this: Quote: First off, bootloaders always start in real mode(16-bit), as that is how the processor starts up, and is why your bootloader wouldn't work as 32-bit(protected mode) code. As for the ALIGN(4096)..
With the Intel x86 32-bit processors, a pages size is fixed at 4KB. 4096 bytes = 4KB. That way, when you enable paging, your code and variables aren't mangled.
But honestly, RTFM!!
He's probably confused not knowing 0x66 or 0x67 instruction prefix makes it 32-bits in real mode. RTFM!! Real mode allows 32-bit instructions if you prefix them, but segmentation still exists, so it's not like being in 32-bit mode. I happen to identity map virtual to physical and never touch my page tables once they're set-up, for the most part. My memory management code allocates 512 byte "pages" -- I can do that because it's nothing to do with hardware pages, just a unit of allocation. Let me preempt you... in 64-bit mode you have 4K and 2Meg page table entry sizes. RTFM -- it's not 4K/4Meg like 32-bit mode. I happen to have my page tables map everything in 2Meg pages sizes except the first 2Meg. I'll bet you're still confused, so reread this a few times and open your Intel books and study 64-bit mode.
|
Tue Mar 30, 2010 7:05 pm |
|
![](./styles/serenity/theme/images/spacer.gif) |
Terry A. Davis
Joined: Tue Jan 19, 2010 11:51 pm Posts: 66
|
![Post Post](./styles/serenity/imageset/icon_topic_latest.gif) Re: Wanting to use the "hello world" bootloader code
Quote: Hi I'm just starting out, I've read a number of tutorials and I want to know if what I think I have learned is correct.
1. Firstly is setting up the GDT like in JamesM's tutorial enough if I'm going to use paging as a protection mechanism or when changing tasks do I need to modify it?
2. Secondly does each thread need a user stack and a kernel stack?
3. Thirdly how do I set a size to a stack and grow it when it runs out of room?
Thank you
My scheme of not using paging does not allow growing the stack. It sucks, but there are lots of advantages that offset it. Quote: I assume that by "ignored" you mean that you are never receiving an IRQ? Are you ever reading port 0x1f7? Do you have the PIC masked?
Also, you should not be using REP OUTSW -- it will not work on real hardware. You need a tiny delay between each output word.
I'm targeting 64-bit or better hardware, not everything back to 386. I use REP OUTSD, actually. The ICH support chips have a DWORD size port, except if you go to far back in time. http://www.intel.com/assets/PDF/datasheet/319973.pdfIf you do port I/O like me, you'll soon discover 0x1f7 is not the only possible location. I made my port I/O handle any port locations. There are two port numbers you need -- The ATA ports are not contiguous. You can prompt for port numbers expecting users to check system information for their machine, or you can read the ICH chip for SATA port numbers, but who knows if they have an ICH chip--they might not.
|
Tue Mar 30, 2010 9:12 pm |
|
![](./styles/serenity/theme/images/spacer.gif) |
Terry A. Davis
Joined: Tue Jan 19, 2010 11:51 pm Posts: 66
|
![Post Post](./styles/serenity/imageset/icon_topic_latest.gif) Re: Wanting to use the "hello world" bootloader code
http://forum.osdev.org/viewtopic.php?f=2&p=174505#p174505Reinventing Linux. They will mislead you in that direction and praise you as you go down the pointless path. That is their champion they are puttin-up against me. A chorus of wonderfully natural heart-felt unforced spontaneous acclaims. Goading me? http://users.softlab.ntua.gr/~ttsiod/renderer.htmlThat's cool. http://forum.osdev.org/viewtopic.php?f=11&t=21431They are forever disputing my 64-bit status. "I8" is an 8-byte integer, not bit. What the fuck would an I2 be, moron's! I0, I1, I2, I4, I8, U0, U1, U2, U4, U8, F8. Signed, unsigned and float.
|
Sat Apr 03, 2010 9:10 pm |
|
![](./styles/serenity/theme/images/spacer.gif) |
Terry A. Davis
Joined: Tue Jan 19, 2010 11:51 pm Posts: 66
|
![Post Post](./styles/serenity/imageset/icon_topic_latest.gif) Re: Wanting to use the "hello world" bootloader code
I got floppy spec info from Linux code. Don't have floppy anymore, do I? Does the disease still linger? Cannot cut-out this cancer? You're building bad Karma with God, I should warn you. Stupid fucks. You're a special kind of stupid. God says... Quote: conflicting infirmities displease more request shoulders interposed Unless plunged face servitude predict those manifested proud production some detesting windy armed dimensions wandering sawest dir baptism artificer displeasing slackness placed Archive sweetly ordered eunuchs kingdom inserted fashion endure thinking path wordy If you know about my knee injury, why are you asking? In 2002 I ran and jump-kicked a wall, blowing-out my knee, fantacizing about fighting a knight, like some Brave Heart sort of thing. Why are you asking if you know? God says... Quote: pleasureableness whose profitable swept Then sword willed forethink compact councillor escaped factito antecedent extolled essence flesh bends doted varied abundant sailors stablished alloy pictures unfair robber compressed sustenance chambering repute necessary proprietary overpast clear heinous Continence correction pardoned gainsayers saidst dearest cubits deride incomparably Balaneion riotous weakened promo made grieved month spectacles horror instructed gentle wondrously relate ruminating unless served FTP connects Couldest tasting Virgil unformed bark fashioned Epaphroditus slept searched explain slaves ftp incensed opinionative Augustine XII tranquil anxiously prayers discontent bubbling violets discovers doctrine creating otherwhiles sores wages despisedst groaning All doings twisted functions bespotted frame hours preceded disentangle status amiss admonished Sodom inexpressible having dangers Association stoop proved reconciliation command Courage storing choose Circensian dive rise remembering hundred good ways envy educated sale odour compendiously dieth believer parched forasmuch Now, I have a question for you. What the fuck is you're logic? You know this is a spirit? Surely, you don't think this will finish well for you, do you? Do unto others as you'd have done to you is the law. Eye for Eye, tooth for tooth is God's law. Forgive us our tresspasses because they will be done back to us and we will forgive. In 1996, my first episode, thinking the end of the world. I abandoned my car in the middle of a road and walked, thinking oil was bad. A cop showed up and I got in and he suddenly flipped a U-turn back toward my car. I dived-out of the passenger seat and broke my collar bone. The 2002 knee injure was also a crazy injury. These offset the 1999 crazy pedestrian hit I did -- I know I hurt his knee and shoulder. Do you see the light, yet? Like some 2001 Space Odesee monkey? That's why I keep telling you you're stupid. Judge not lest you be judged. This will not end well for you. Quote: food repeat_after_me incoming well_golly furious what_luck quit_it thats_for_me_to_know special_case nasty quite
|
Tue Apr 06, 2010 9:38 am |
|
![](./styles/serenity/theme/images/spacer.gif) |
Terry A. Davis
Joined: Tue Jan 19, 2010 11:51 pm Posts: 66
|
![Post Post](./styles/serenity/imageset/icon_topic_latest.gif) Re: Wanting to use the "hello world" bootloader code
Let's talk of intellectual property. Implementing an ATA port I/O package Code: U0 ATABlkSelect(LTBlkDev *bdev,U8 blk,U8 cnt) { if (bdev->type!=LTBDT_ATAPI && bdev->base1) OutU1(bdev->base1+ATAR1_CONTROL,0x8); if (bdev->flags & LTBDF_EXT_SIZE) { OutU1(bdev->base0+ATAR0_NSECTOR,cnt.u1[1]); OutU1(bdev->base0+ATAR0_SECTOR,blk.u1[3]); OutU1(bdev->base0+ATAR0_LCYL,blk.u1[4]); OutU1(bdev->base0+ATAR0_HCYL,blk.u1[5]); OutU1(bdev->base0+ATAR0_NSECTOR,cnt); OutU1(bdev->base0+ATAR0_SECTOR,blk); OutU1(bdev->base0+ATAR0_LCYL,blk.u1[1]); OutU1(bdev->base0+ATAR0_HCYL,blk.u1[2]); OutU1(bdev->base0+ATAR0_SELECT,0xEF|bdev->unit<<4); } else { OutU1(bdev->base0+ATAR0_NSECTOR,cnt); OutU1(bdev->base0+ATAR0_SECTOR,blk); OutU1(bdev->base0+ATAR0_LCYL,blk.u1[1]); OutU1(bdev->base0+ATAR0_HCYL,blk.u1[2]); OutU1(bdev->base0+ATAR0_SELECT,0xE0|bdev->unit<<4|blk.u1[3]); } }
BoolI8 ATAWaitNotBUSY(LTBlkDev *bdev,LTDate timeout) { while (TRUE) { if (InU1(bdev->base0+ATAR0_STATUS)&S_BUSY) Yield; else return TRUE; if (timeout && BootTime>timeout) return FALSE; } }
BoolI8 ATAWaitDRQ(LTBlkDev *bdev,LTDate timeout) { while (TRUE) { if (!(InU1(bdev->base0+ATAR0_STATUS)&S_DRQ)) Yield; else return TRUE; if (timeout && BootTime>timeout) return FALSE; } }
BoolI8 ATANop(LTBlkDev *bdev,LTDate timeout) { if (bdev->flags & LTBDF_EXT_SIZE) OutU1(bdev->base0+ATAR0_SELECT,0xEF|bdev->unit<<4); else OutU1(bdev->base0+ATAR0_SELECT,0xE0|bdev->unit<<4); OutU1(bdev->base0+ATAR0_FEATURE,0); OutU1(bdev->base0+ATAR0_CMD,ATA_NOP); return ATAWaitNotBUSY(bdev,timeout); }
U0 ATACmd(LTBlkDev *bdev,U1 cmd) { OutU1(bdev->base0+ATAR0_FEATURE,0); OutU1(bdev->base0+ATAR0_CMD,cmd); bdev->last_time=GetTimeStamp; PortNop; }
That's much of the code. Trace for me the evolution from Linux. Just as one might do math proofs by breaking into theorems and axioms, we'd have to trace the fascicles to see if any Linux intellectual property were still present. The first point is fascicles might no longer be present. The floppy code was removed, for example. I got the spec for ATA, fixing things, a superset of the fascicles from Linux, if any exist after applying the following: Did Linux originate the intellectual property? I did my malloc/free heap like Ticketmaster, but they might have gotten it somewhere else. We must throw-out anything not property of Linux. To take this to court we must analyse fascicles. A) The port numbers. Is a number from an IBM spec owned by Linux? B) The labels for port numbers. C) the unit bit, for example. Does Linux own that? I find it hard to find anything creative or intellectual from Linux. Just numbers from an ATA spec they did not create. How you use them, perhaps? If you recreate a book, typing it in, it's still copyrighted... even if somehow independently generated. An 8x8 font is copyrighted, but what if there aren't alternatives? If I make an 8x8 font, I'm gonna likely independently recreate some identical letters pixel by pixel. If there is only one way to do something, someone owns it or nobody owns it. You have to put block numbers in LCYL and HCYL, I don't care where you learned it. In short, this ATA code is not owned by linux. They might claim a tricky technique to write the regiosters or something. That would be a fascicle they could own. I did learn about REP INSW from their code. I discovered I could do REP INSD from the Intel ICH manual. If I break it into a INSD loop, am I free? Spell-out which fascicles in my code you claim to own.
|
Tue Apr 06, 2010 11:14 am |
|
![](./styles/serenity/theme/images/spacer.gif) |
Terry A. Davis
Joined: Tue Jan 19, 2010 11:51 pm Posts: 66
|
![Post Post](./styles/serenity/imageset/icon_topic_latest.gif) Re: Wanting to use the "hello world" bootloader code
I worked on Ticketmaster's VAX operating system and was trusted with everything. At Xytec, I installed a password capability in the Bank of England's fascility. Our company did software to run a currency inspection system to removed bank notes with blotches or whatever. I am a white hat. I'll sue if you slander me... or sic God on your ass. God's the top law enforcement officer. God says... Quote: forging funding discussion millennium intelligible figure bemoaning cleanse agito broughtest tamer plot VERSIONS ruminate Ambrose propoundest citizen maintaining renewed hard sending deprived Suppose aim two
|
Tue Apr 06, 2010 11:34 am |
|
![](./styles/serenity/theme/images/spacer.gif) |
Terry A. Davis
Joined: Tue Jan 19, 2010 11:51 pm Posts: 66
|
![Post Post](./styles/serenity/imageset/icon_topic_latest.gif) Re: Wanting to use the "hello world" bootloader code
You should be so luck: http://blogs.walkerart.org/newmedia/2010/04/06/glimpse-inside-blog-spammers-tools/Take a nanosecond stop watch, stop it without looking, each time you sample it, use the number for a word, phrase, page or whatever. It's tongues. http://www.usccb.org/nab/bible/1corinthians/1corinthians14.htmWhat part of "God" do you not understand? God says... Quote: appeared Thinkest laws Rebuke wanting wildness vehemently gilded educate discord manors dwellest lilies salted native seemly charity saw always correspondence comely forethought Computers conscious extracted spirits witting sufficed strangely warned comprehendeth Title denoted consistent
|
Tue Apr 06, 2010 11:48 am |
|
![](./styles/serenity/theme/images/spacer.gif) |
Terry A. Davis
Joined: Tue Jan 19, 2010 11:51 pm Posts: 66
|
![Post Post](./styles/serenity/imageset/icon_topic_latest.gif) Re: Wanting to use the "hello world" bootloader code
I don't use Interrupts for disk. Prevents a source of incompatibility. Bet you didn't know you could do multitasking without interrupts here. Task yields to the scheduler each time it checks. Cooperative multitasking. Ha! Code: BoolI8 ATAWaitDRQ(LTBlkDev *bdev,LTDate timeout) { while (TRUE) { if (!(InU1(bdev->base0+ATAR0_STATUS)&S_DRQ)) Yield; else return TRUE; if (timeout && BootTime>timeout) return FALSE; } }
BoolI8 ATAGetResult(LTBlkDev *bdev,U1 *buf,I8 cnt,I8 _avail,BoolI8 one_read,LTDate timeout=0) { I8 avail,overflow; bdev->flags&=~LTBDF_LAST_WAS_WRITE; MemSet(buf,0,cnt); while (cnt) { if (!ATAWaitDRQ(bdev,timeout)) return FALSE; if (_avail) avail=_avail; else avail=InU1(bdev->base0+ATAR0_HCYL)<<8+InU1(bdev->base0+ATAR0_LCYL); if (avail) { if (avail>cnt) { overflow=avail-cnt; avail=cnt; } else overflow=0; if (avail&2) RepInU2(buf,avail>>1,bdev->base0+ATAR0_DATA); else RepInU4(buf,avail>>2,bdev->base0+ATAR0_DATA); cnt-=avail; buf+=avail; while (overflow) { InU2(bdev->base0+ATAR0_DATA); overflow-=2; } if (one_read) break; } } return ATAWaitNotBUSY(bdev,timeout); }
U0 ATAReadBlks(LTBlkDev *bdev,U1 *buf, U8 blk, U8 cnt) { I8 retries=3; BoolI1 unlock=BlkDevLock(bdev);
retry: ATABlkSelect(bdev,blk,cnt); if (bdev->flags & LTBDF_EXT_SIZE) ATACmd(bdev,ATA_MULTREAD_EXT); else ATACmd(bdev,ATA_MULTREAD); if (!ATAGetResult(bdev,buf,cnt*bdev->blk_size,BLK_SIZE,FALSE,BootTime+LTDATE_FREQ)) { if (retries--) { ATAWaitNotBUSY(bdev,0); goto retry; } else throw(EXCEPT_BLKDEV,6); }
disk_reads+=(cnt*bdev->blk_size)>>BLK_SIZE_BITS; if (unlock) BlkDevUnlock(bdev); }
Monkey Mine's done and compatible and wildly successful ![Smile :-)](./images/smilies/icon_e_smile.gif) Quote: alternates Pylades meekness truth animate Himself vile Substance daily artifices sinner mountain treasured criticised fury comprised glorifies prepare consecration auditor surf FOR clasp bubblings Thanks satisfied prior murdered calmly hadst anticipating far edged expends repress doubts Same
|
Tue Apr 06, 2010 12:17 pm |
|
|
Who is online |
Users browsing this forum: No registered users and 7 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|