Wednesday, September 14, 2011

Bootloader


The below assembly code loads the secondary bootloader (boot2.bin) at address 0x8000 from the FAT12 filesystem and jumps to it.


;_______________________________________________
;    File name : boot.asm |
;    Authour : M.Alexander |
;    Mail : programmer_83@hotmail.com |
;    Date : 09-05-2004 |
;    Description : Primary Bootloader |
;_______________________________________________|


[BITS 16]


; Memory Map
;_______________________________________________
; |
;      _____________________ |
;     |    |  <-- 0x0000 |
;     |    | |
;     |        STACK    | |
;     |    | |
;     |_____________________|  <-- 0x05FF |
;     |    |  <-- 0x0600 |
;     |       FAT COPY    | |
;     |_____________________|  <-- 0x1800 |
;     |////////UNUSED///////| |
;     |_____________________|  <-- 0x2000 |
;     |    | |
;     |    ROOT DIRECTORY   | |
;     |_____________________|  <-- 0x3C00 |
;     |/////////////////////| |
;     |////////UNUSED///////| |
;     |/////////////////////| |
;     |_____________________|  <-- 0x7C00 |
;     |    | |
;     | PRIMARY BOOTLOADER  | |
;     |_____________________|  <-- 0x7E00 |
;     |/////////////////////| |
;     |///////UNUSED////////| |
;     |/////////////////////| |
;     |_____________________|  <-- 0x8000 |
;     |    | |
;     |SECONDARY BOOTLOADER | |
;     |_____________________|  <-- ?? |
; |
;_______________________________________________/


%define FAT_CPY 0x0600
%define DIR_CPY 0x2000
%define SEC_BL 0x8000


[org 0x7C00]


jmp short start
nop


OEM_IDENT db 'FAT12FLP'
BYTES_PER_SCT dw 0200h
SCTS_PER_CLST db 01h
RESERVED_SCTS dw 01h
NO_OF_FATS db 02h
ROOT_ENT dw 0E0h
NO_OF_SCTS dw 0B40h
MEDIA_DCPTR db 0F0h
SCTS_PER_FAT dw 09h
SCTS_PER_TRK dw 012h
HDS_PER_CYL dw 02h
HDN_SCTS dd 0h


start:


mov ax, 0
mov ds, ax
mov es, ax
mov ss, ax       ; Initialize segment registers
mov ax, 0x5ff
mov sp, ax       ; Setup Stack space


sti       ; Enable Interrupts


;____________________________________________________________.
;     Loads FAT copy into main memory at address 0x0600      |
;____________________________________________________________|


xor ax, ax
add word ax, [RESERVED_SCTS]
call trans_add
mov ah, 0x02
mov al, [SCTS_PER_FAT]
mov dl, 0x00
mov bx, FAT_CPY
int 13h


;____________________________________________________________.
;     Loads Directory Entries into main memory at     |
;     address 0x0600     |
;____________________________________________________________|


mov al, [SCTS_PER_FAT]
mul byte [NO_OF_FATS]
add word ax, [RESERVED_SCTS]
call trans_add
mov ah, 0x02
mov al, 0x0E
mov dl, 0x00
mov bx, DIR_CPY
int 13h


;____________________________________________________________.
;  Calculates the start of data area and saves it in the     |
;  variable DATA_AREA for future use.     |
;____________________________________________________________|


mov ax, [SCTS_PER_FAT]
mov bx, [NO_OF_FATS]
mul bx
add ax, [RESERVED_SCTS]
mov bx, ax
mov ax, [ROOT_ENT]
shl ax, 0x05
shr ax, 0x09
add ax, bx
mov [DATA_AREA], ax


;____________________________________________________________.
;     Searching for the secondary file begins here.     |
;____________________________________________________________|


mov bx, [ROOT_ENT] ; Move the number of root entries into bx (counter)
mov dx, DIR_CPY ; Move the address of Directory entry into dx
srch:
cld ; Clear the direction flag
mov di, sec_file ; Move the address of the secondary file into di
mov si, dx ; Load the source address
mov cx, 0x0b ; Number of characters to compare (8+3)
repe cmpsb ; Repeat till the characters not equal. Maximum 0x0b times
jnz short next ; If not found, try next entry




;____________________________________________________________.
;  Loads the secondary file at the address SEC_BL declared   |
;  earlier.     |
;____________________________________________________________|


mov bx, SEC_BL
mov si, dx
add si, 0x1A ; Byte 26 & 27 of the file entry
mov word ax,[si] ; (Entry cluster value)
push ax ; Push the starting cluster to the stack
load:
xor eax, eax
xor ecx, ecx
xor dx, dx ; Clear out necessary registers


pop ax ; Pop the last computed value for the sector
push ax ; Again save it for future use


cmp ax, 0x0FFF ; If End of sector for the file, jump to exit
jz exit


mov cl, [DATA_AREA]
dec ax
dec ax ; Subtract 2 from the next sector value
add ax, cx ; Converts the data sector into LBA
call trans_add ; Converts LBA into CHS


mov ax, 0x0201
mov dl, 0x00
int 13h ; Read the next data cluster into the main memory


add bx, 0x200 ; Increment the file pointer to load the sector


xor ax, ax
pop ax ; Pop the sector value from the stack
mov cx, 0x03
mul cx ; Multiply the value with 3
rcr ax, 1 ; Divide it by 2 (3/2 = 1.5)
jc carry ; If carry set, decimal number


mov si, ax
add si, 0x0600
mov word ax, [si]
and ax, 0x0fff
push ax
jmp load
carry:
mov si, ax
add si, 0x0600
mov word ax, [si]
shr ax, 4
push ax
jmp load


jmp $ ; File found. write code here
next:
dec bx ; Decrement number of entries to check still
jz exit ; If zero, file not found
add dx, 0x20 ; Point to next entry
jmp short srch ; Compare next entry


exit:
jmp 0000:8000h ; Jump to secondary boot loader code




trans_add:
;____________________________________________________________.
;  FUNCTION :  Translates LBA sector number into CHS value   |
;  INPUT    :  AX = LBA Sector     |
;  OUTPUT   :  CH = Cylinder, DH = Head, CL = Sector     |
;     |
;  FORMULA USED:     |
;  sector   = (LBA % SPT) + 1     |
;  Head   = (LBA / SPT) % HPC     |
;  Cylinder = (LBA / SPT) / HPC     |
;____________________________________________________________|
;     |
div word [SCTS_PER_TRK]   ; LBA / SPT     |
inc dl      ; dl = (LBA % SPT) + 1 |
mov cl, dl      ; cl = sector     |
xor dx, dx      ; Clear out dx reg.    |
div word [HDS_PER_CYL]    ; (LBA / SPT) / HPC    |
mov ch, al      ; ch = cylinder     |
mov dh, dl      ; dh = head     |
ret      ; Return     |
;____________________________________________________________|






print:
;____________________________________________________________.
;  FUNCTION : Prints a string     |
;  INPUT    : SI = String Address     |
;  OUTPUT   : Prints the string     |
;____________________________________________________________|
;     |
push ax ;     |
push bx ;     |
pchar: ;     |
cld ;     |
lodsb ;     |
or al, al ;     |
jz pexit ;     |
mov ah, 0x0e ;     |
mov bx, 0x0007 ;     |
int 10h ;     |
jmp pchar ;     |
pexit: ;     |
pop bx ;     |
pop ax ;     |
ret ;     |
;____________________________________________________________|




sec_file db "BOOT2 BIN"
file_nt_fnd db CR,LF,'File not found',0
file_fnd db CR,LF,'File found',0
DATA_AREA db 0x00
FILE_BUF dw 0x8000


CR equ 0x0d
LF equ 0x0a


times(510-($-$$)) db 0
dw 0xaa55


Wednesday, August 03, 2011

iOmega Screenplay Director

I am a moviebuff and used to watch lot of English, Tamil, Korean, Japanese movies. I felt a media player connected to TV in my living room would be better compared to watching movies in laptop. So, here is my review of the latest gadget in my home. iOmega Screenplay Director. My first choice of media player was WD Live TV because of its low cost (it doesn't come with internal HDD) and I convinced myself to go for Screenplay Director, as one of my colleagues own it. Also, this is the only media player available in Chennai stores. It comes with two years warranty.



Screenplay Director comes with 1TB and 2TB versions. I gone for 1TB version. I copied my movie collection from my laptop and external HDD that I had. I was happy about the space that I have, which could hold hell a lot of movies.

Specification:
HDD : 1 TB / 2 TB
Video formats supported: MPEG1, MPEG2, MPEG4 (upto 1080p), H.264, XviD, WMV, VC-1
Audio formats supported: AAC, AC3, FLAC, MP3, Ogg Vorbis, WAV, WMA
Photo formats supported: BMP, GIF, JPG, PNG, TIFF
Output ports: Composite (SD), Component, HDMI, Optical audio.
USB ports: 3
Ethernet port: 1

The pack comes with only Composite cable.

Design:
The media player is not a sleek one compared to other media players in market. The remote doesn't look impressive and most of the keys have dual purpose. For example, the rew / fwd, vol up / vol dwn keys have a single key and these keys are very small to press what you want to. There are Video, Music and Photo keys in the remote that lets you directly jump instead of pressing the Home key and selecting videos or music or photos.

Poor software:
The software is the worst part of the gadget. There are so many bugs, which leads you to restart the device most of the time to recover. The boot up time also takes around 2.30 minutes :(

User interface:
The UI design is okay. Not worst, not the best. There is no customization possible like changing the color of the screen.

Navigation:
The navigation is designed badly. While watching a movie, if you decide to play another movie, you press the Video key in remote. This takes you to the list of available HDD (internal and external) menu, instead of taking you to the last selected movie folder. I felt this is quite annoying at times. You have to keep scrolling all the times.

Video:
I haven't used any other media player, but the quality of video that I get in Composite (SD) is quite fascinating. The clarity of the video is really very good. However, some of my downloaded Tamil movies doesn't play with this media player. Not sure why is it. Haven't explored on this. There is no way to customize the subtitles, either the location or the size of the font on the screen. The text is small to read. The player doesn't upscale the audio that comes in the video. Sometimes, the audio is too low that I have to keep 100% volume in my TV.

Photo:
They haven't cared much to provide a good photo viewing experience. The wide screen photos are just scaled in composite output, which doesn't appeal at all. There is no way to configure the speed for transition.

Youtube:
The media player doesn't have inbuild wifi capability. However, you could plug in a iOmega wifi dongle in the USB port and connect to internet. I haven't bought one dongle yet. The software supports only YouTube videos from internet.

Torrent support:
I think these guys thought about all the moviebuffs in the world, who mostly use torrents to download illegal movies. This player allows you to download any files over torrents if you have added it.

I wouldn't recommend this media player, except for its good quality video. Most of the LED TVs nowadays come with USB source, where you could plug in an external HDD and play any type of video format. If you are planning to buy such a TV shortly, don't think of going for a media player.

Tuesday, August 03, 2010

miniDLNA (Ubuntu) with Samsung Galaxy S

I have been trying to play media files from my laptop running Ubuntu 10.04 through MediaTomb server from Samsung Galaxy S mobile. The mobile was able to read the CDS shared by the server. However, it was not able to playback the video from the server (I kept getting Sorry, the file could not be played). I started the server in debug mode (-D option) and found that galaxy was trying to request the file by sending the complete web server address., i.e., http://:/content/media/file/... . While other DLNA devices request the URL relative to the root folder in the server., i.e., /content/media/...

Even resolving the above issue by fixing the MediaTomb didn't help out. Still galaxy did not get the content for playback (a different issue than the above one). I happened to know that MediaTomb is not 100% DLNA compliant. Tried out miniDLNA and it worked out. miniDLNA seems to be a simple tool that will satisfy your media server needs. miniDLNA is available at https://sourceforge.net/projects/minidlna/

Saturday, May 08, 2010

Youtube 3D

Youtube player supports Stereoscopy (3D) content. The player provides various options to deliver 3D content differently to your browser. There is an option “Cross-eyed” to watch 3D (with 3D) with your naked eye. But, you should strain your eyes to overlap two images. (I tried and couldn’t make it L). Other options should allow you to watch the video using the 3D special glasses. Currently, youtube doesn’t support Polarized 3D glasses.

Watch this video. http://www.youtube.com/watch?v=6RFuRY7azgA. Notice the “3D” option in the player. Seems there are many 3D content available in youtube. Next thing, I am gonna do is buy a 3D glass J. No wonder if full 3D movies make into youtube in near future.

Copying text from the video:
>>

HOW DID I MAKE THIS?
I simply used 2 identical (very cheap) cameras and placed them in the same general direction (both level with the lenses separated about 2 1/2 inches from each other). Then I resized the videos in editing and placed them next to each other (like you see in the "cross-eyed" setting). Once it was uploaded I added a few tags to trigger YouTube's new 3D viewing feature. The tag "yt3d:enable=true yt3d:aspect=3.55:4" is a custom tag I made specifically for this video and may not work for your video if you use it but it wouldn't hurt to try I guess. So just put that code into your tags if your video looks like mine.

HOW TO ANIMATE IN 3D:
Unfortunately, I had to cross my eyes to edit in 3D. I don't have any big fancy programs or a team to animate for me like most 3D studios have. So I like to keep it simple. It was a pain in the arse making this but it worked and I'm happy for that.

Camera used:
2 Flipcams

<<

http://googlesystem.blogspot.com/2009/07/youtube-3d.html

Saturday, April 24, 2010

Android on iPhone

Its really cool!!!

Android running on an iPhone. A member of iPhone development team called Planetbeing have ported Android to run on iPhone. iPhone can be configured to dual boot iPhone OS and Android phone. I even had a glimpse of Android running on iPhone in one of my friend's mobile. I would rate the experience is quiet better than the Samsung I5700 galaxy spica The graphics transition is quiet faster.

The port is currently available only in the first generation iPhones. Hope it would soon be available in iPhone 3G and 3GS models. The source code is available online here

Have a glimpse on this video.


Wednesday, April 21, 2010

HJSplit for Linux

If you are looking for an alternative method to join the splited files using HJSplit program, there is one for Linux users. The tool is used to split and join a big file. The splited files are named in the format file_name.avi.001, file_name.avi.002 and so on by the tool.

Linux users, just use the 'cat' command to merge the files. The syntax that I used is as below:

$ cat file_name.avi.* > filename.avi

This works because the cat command takes filenames in alphabetical order and merges the files.

- Have fun.

Saturday, April 17, 2010

MeeGo 1.0 first look

Intel's Moblin and Nokia's Maemo merged together to give birth to MeeGo mobile operating system. MeeGo is a Linux-based operating system with Qt support for UI. The OS currently support ARM and x86 architectures. As the OS has been released as open source (hosted by Linux Foundation), soon there will be support for various architectures. It is claimed that MeeGo is not based on any other Linux distros. But, the packages will use the existing Fedora's .rpm.

MeeGo can be downloaded here and developer resources are available here.

Look at the first preview of MeeGo running in Netbook.


Sunday, April 11, 2010

Samsung I5700 galaxy spica

If you are looking for a cheaper and good Android based mobile, consider Samsung I5700 galaxy spica. Initial looks and feature of this phone looks promising. In fact, the main reason that I am considering this model is it comes with Qualcomm 800MHz processor, comparing to 200MHz processor in my current mobile. Listed below are the basic features of this model:
  • 800 MHz Qualcomm processor.
  • Android v1.5, you can upgrade to v2.1.
  • 16M color, compared to 256k color in my current mobile.
  • 3.5 mm audio jack. SE users will understand why this is a required feature :)
  • 3.2" TFT capacitive touch screen display.
  • wi-fi, gps
  • The most appealing thing is you get a xVid/divX player application.
The big brother of this model is Samsung I7500 galaxy spica, which came with a slower processor. You will feel the difference with 800MHz processor speed.

With Android, you have a open box. You can write and use your own applications. Current market price is around Rs.12,000. No wonder, if I buy this as my other mobile soon :)

Friday, November 06, 2009

Ubuntu 9.10

Ubuntu 9.10 seems to be a worst product from Canonical. 9.10 was on a high expectation. The next release after 9.10 is going to be a Long Term Support product by Canonical Ltd. The other reason is the new Windows 7 from MS received many good responses around the world.

Most of the users upgraded / freshly installed 9.10 are hit by black screen issues. Some of the devices which worked in 9.04 discontinued to work in 9.10. It is always better to wait for any new product to arrive in the market, wait until it is reviewed by its users and then decide on buying it. The same applies for software too. I was saved by this simple idea by not installing 9.10 on the day of its release :). It is always good to be not biased.

According to a survey in Ubuntu Forums, around 33% (at the time of writing this) of the Ubuntu users seem to be affected by irrecoverable problems. May be, it is the karma of Ubuntu.

Canonical should have been more responsible. They had a very good market share in distribution based on GNU/Linux. They brought down the complex usability of GNU/Linux distribution to a much easier and simpler usability for end users. That was their success.

On the other side, Windows 7 seems to be a default version for many Windows users next to Windows XP. It seems to be a stable version too. Ubuntu 9.10's failure should have been considered as a success for some Windows 7 royal fans. They think Ubuntu is Linux.

Wednesday, September 02, 2009

Software Freedom Day 2009

Software Freedom Day is being celebrated across the world to promote Free and Open Source Software (FOSS) and celebrate the people behind FOSS. A non-profit company based in USA called Software Freedom International (SFI) coordinates the SFD across the globe. Though, there are many local groups in different regions that celebrates the day by themselves.

I am not totally involved in any of the Open Source projects. But, I could understand the freedom given to the end user in any software that they use. One have full freedom to customize the software for their use and enhance it. I was using pirated editions of Windows in my college days. Now, I have migrated to the FOSS world. I use Ubuntu in my personal laptop. Whatever software that I want to do my day to day activities are also freely available for Linux. This prevents me from stealing others work ;) I am not against M$ or anything. I just prefer to be with FOSS.

The SFD is also celebrated in Chennai. The date is 19 September 2009. The venue planned is Birla Auditorium, Kotturpuram. There are various events, stalls, activities being planned for the day. Lots of people are volunteering themselves to contribute to the event, which is a nice thing.

To learn more about FOSS, visit http://en.wikibooks.org/wiki/FLOSS_Concept_Booklet

I personally feel, though one likes FOSS, they should not be biased to FOSS and grow hatred towards non-FOSS people.

So, have fun. Let the source be with you...

Thursday, February 21, 2008

My Lego Mindstorms Nxt kit


Hurrayyyyy!!!!!!!!!!!

After a long research and lonnnngggg search, finally I got my Lego Mindstorms Nxt (LMN) robotics kit, last weekend. It was a long wait and I was frustrated by Walmart, Fry's Electronics guys. I picked up mine at a Lego retail store in Hillsdale mall. It costed me $260. Costly though. I am not sure, if you could get one in India.


I was evaluating a robotics kit for a long time, as I don't know much of mechanical or electronics to
design bots or construct circuit boards. My research took me to Lego Mindstorms Nxt kit, which is actually meant for 10+ years kids. But, it's okay. There are lot of guys out there working on their innovative ideas on the kit. Those ideas are fascinating.

Let's look at the stuffs that come with the package. The earlier edition of LMN was just called "Lego Mindstorms" and it is in retail no more.
  • The brain of this kit is the NXT brick, which runs 32-bit ARM7 micro-controller. More details later.
  • Three servo motors - for movements, arms or wheels.
  • Ultrasonic sensor - to measure distance to an object.
  • Light sensor - to detect light and color.
  • Sound sensor - to hear sound
  • Touch sensor - to feel the environment
  • 577 lego bricks, screws, etc etc for constructing robots.
The NXT brick has three output ports for motors and four input ports for sensors. The configuration for the NXT brick is as below:
  • 32-bit ARM7 microcontroller
  • 256 Kbytes FLASH, 64 Kbytes RAM
  • 8-bit AVR microcontroller
  • 4 Kbytes FLASH, 512 Byte RAM
  • Bluetooth wireless communication (Bluetooth Class II V2.0 compliant)
  • USB full speed port (12 Mbit/s)
  • 4 input ports, 6-wire cable digital platform (One port includes a IEC 61158 Type 4/EN 50 170 compliant expansion port for future use)
  • 3 output ports, 6-wire cable digital platform
  • 100 x 64 pixel LCD graphical display
  • Loudspeaker - 8 kHz sound quality. Sound channel with 8-bit resolution and 2-16 KHz sample rate.
  • Power source: 6 AA batteries
Now, let us look at the programming environment that comes with the kit. Since the kit was designed for 10+ age group, Lego decided to go with a GUI based programming. The language is called NXT-G. It has a collection of what is called blocks and a number of required blocks are connected together to accomplish a task.

But, it does not stop here. If you are looking for a programming environment similar to C, you are not the first one to think about it. There are pretty good number of development environments/languages that closely resembles ANSI C standards. The widely used OS for NXT kit is LEJOS, a tiny Java VM.

Though I am ready to start my work on this, I am waiting for my current assignments (job) to come to a stop. So that, I would get more time to work on this.

NXT blog: About various languages available for NXT kit.

Pictures are available at http://picasaweb.google.com/alexander.hclt/MyLegoMindstormsNxtKit

Have fun!!!

Wednesday, December 26, 2007

Configuring ALSA driver in Lenovo 3000N100

Guys, It has been a while since I configured audio driver in Linux OS for my Lenovo 3000N100 laptop and made it working. Thanks to guys working in Linux world. They are open-minded and ready to help you out in any trouble.

Here are the steps:
1. Download the ALSA driver package from an FTP site (Google it!!!) and untar it in your home directory.

2. If you really need to configure ALSA for your 3000N100, mail me. I will send you a patch file.

3. Untar the patch file "
patch_realtek.c" and replace the same file in the folder "alsa-driver-xxx/alsa-kernel/pci/hda/"

4. cd to "alsa-driver-xxx" folder.

5. Issue ./configure --with-cards-hda-intel

make

make install

Congrats!!! Your laptop is now ready to ROCK in Linux!!!

- Alexander

Friday, July 13, 2007

Lenovo 3000 N100

I was planning to buy a laptop for quite a long time. After comparing various brands and models, I decided to go for Lenovo 3000 N100 series laptop. I was also looking for a model that would have full support in Linux.

I was struck on choosing a good processor. Intel dual-core architecture is based on Intel Pentium M processor. Intel Core 2 Duo is advanced than Intel dual-core processor, in a way that the former supports IA64. Also, it is designed to consume less power than IDC processor.

Dell laptops come with good configuration for a less price. But, you have to wait for atleast 15 days, until you get your laptop. Also if you are planning to install Linux, Dell is a good choice as Linux have driver support for almost all components.

Lenovo 3000 N100 comes pre-installed with Windows Vista. Windows XP is not written for Multi-processor. So, installing Windows XP is a bad idea in a dual-core laptop. I got my laptop in a week after placing my order.

Partitioning was quite easy in Vista. The model comes with 105 GB of single primary partition. 6 GB is dedicated to windows recovery partition. I used diskpart.exe (a command-line utility that comes with Vista) to shrink the primary partition. I could only shrink the partition for a maximum of 32 GB. And created another primary partition. Though it's not bad, as Linux could just mount Vista partition.

Earlier, I got my Ubuntu AMD64-bit edition from http://www.ubuntu.com/getubuntu Just booted the CD. Ubuntu desktop welcomed me with 'Install' icon. You have to just cross 7 easy steps for easy installation.

But unfortunately, audio doesn't work with this model in Linux. In Vista, it works. But, the sound is too low. You have to use a headphone to listen music or to watch movies. Hope the tutorials in ubuntuforums will help me.

Alexander.

Tuesday, July 10, 2007

Inside Apple iPhone





[Courtesy: embedded.com]

Tuesday, April 24, 2007

SickSack

SickSack (Sounds like Zig Zag).

Guess what? It's a robot. Yes, follows a black line on the floor like a snake. It has been designed by two innovative guys, Lars Pontoppidan and Aske Olsson in USA.
Click the link, http://pontoppidan.info/lars/index.php?proj=sicksack for more details about the robot. Don't forget to check out the videos.

It has been my dream for quite some time now, to do some work-around in Robotics. Hope it would work out some day.

-NOTNULL.

Friday, January 05, 2007

The Google Story

Recently, I happened to read the book "The Google Story" by David A. Vise. What to say? It's really a wonderful book, which explains the complete story of Google. It has many interesting information right from Google cook Charlie Ayer, Google stock, Eric Schmidt joining Google, etc. Page by page, it ties the reader to the book.

Tuesday, January 02, 2007

Recovering from lost Windows boot loader

When you install the boot loader (either LILO or GRUB) on the MBR, it replaces the MS-DOS boot loader or any other boot loader that may be there, such as the Windows NT loader. If you have problems with your installation or you simply want to restore the original boot loader, you can do one of the following.

  • If you're running LILO, you can boot Linux from a floppy or CD and restore the boot sector, which LILO automatically backs up:

    % /sbin/lilo -u
  • If you have the capability, boot to DOS and run the fdisk command with a special option that rebuilds the MBR:

    C:> fdisk /mbr
  • For Windows 2000 and Windows XP, which do not have an fdisk command, boot your computer from the Windows CD (or the Windows boot floppies if you can't boot from your CD drive). When you see "Welcome to Setup," press R (for repair) and, in Windows 2000, you then press C. Select your Windows installation from the numbered list that is displayed (there may be only one entry) and enter the administrator password at the prompt. Enter the command fixmbr at the command-line prompt and confirm it with y. After the MBR has been restored, type exit to reboot.

Tuesday, June 27, 2006

.bss ???

What is a BSS segment?

Most of the guys ask me this question. This is some segment in your application similar to .text, .data and .stack. All the un-initialized variables go into this section, rather than .data segment. This is to reduce the size of your .exe or .o files.

For example, if you have declared a variable "int a", it goes into the .bss segment. The compiler will not allocate space for "a" in the executable file. Instead, it will accumulate such variables and calculate the total number of bytes and add it in the header.

So your application will not have the space allocated, when it is in secondary memory. Once it is loaded into the primary memory, the number of bytes for the .bss segment is read from the header and allocated in RAM.

- Alexander.

Friday, April 28, 2006

Kernel @ 1 MB

Till now, secondary loader loads the kernel at 0x9000. Now, the loader will load the kernel at 1MB mark. Also, I have created a linker.ld file to link the kernel at 0x100000. Below is my linker.ld script:

ENTRY (_start32)

SECTIONS
{
.text 0x100000 :
{ *(.text) }

.data :
{ *(.data) }

.bss :
{ *(.bss) }
}
  • I have implemented PMM (Physical Memory Manager) in my kernel, which runs below VMM (Virtual Memory Mapper). Though, it is in its priliminary stage.
  • init_pmm() - Will initialize the stack, which holds the address of free pages. The stack is initialized based on the memory map passed by the LEXOS' secondary bootloader. PMM will ignore any usable memory below 1 MB, as it is reserved for V86 mode.
  • alloc_page() - Will pop a free page from the stack and return it to the calling thread. The PMM returns the physical address of the free page. This address will be mapped by the VMM to the process' virtual address space.
  • free_page() - Will push the page to be freed into the stack.

Thursday, December 15, 2005

LEXOS' MM

Lexos will use buddy system algorithm for page allocator. I am still learning buddy allocator, since, I don't find much free time nowadays. Flaws in memory management algorithms will make an operating system weaker. So, I am taking much time to learn and design buddy allocator in my OS.
Lexos will have VMM on top of PMM. PMM (Physical Memory Manager) will service the applications and kernel by providing and freeing page frames on demand. The allocated pages will be mapped into virtual address by VMM (Virtual Memory Mapper).

Edit: As for the time being, I have planned to use stack based approach to manage physical page frames. Later, I would use buddy allocator. Though, I am thinking of using a modified version of stack-based approach, which would have individual stack that holds free pages in the order of 2^n.