Saturday, September 3, 2011

OSDEV Series - Episode 2.2: Short recap

Theory: RAM memory

  • contains: code, data
  • indexed linearly, using hexadecimal numbers
  • measured in bytes and multiples (kilobytes, megabytes, gigabytes, terabytes etc)


Frequently used units of data measurement:
  • bit = 1 or 0
  • nibble = 4 bits (hex digit)
  • byte = 8 bits
  • word = 2 bytes = 16 bits
  • double word (dword) = 4 bytes = 32 bits
  • quadruple word (qword) = 8 bytes = 64 bits

Memory map:
  • 'low' memory (under 1 mb)
  • 'upper' memory (above 1 mb)

The separation appeared in the 16-bit era. At the beginning, 16-bit indexed memory could only reach 64kb in size (0xFFFF is the maximum number in 16 bits). Because engineers didn't imagine that anything would need more than 640kb of memory, they came up with the Segment:Offset memory addressing scheme, which addresses memory using 32 bits.

In the Segment:Offset addressing scheme, the address is specified using 2 words. The first one is the segment; every segment has 64kb in size, and a new segment starts every 16 bytes. This means that the segments overlap each other.  The other word is self explanatory.

There are many ways to specify the same address using this memory scheme, for example:
  • Linear address: 0xA0000 (this is where the video ram starts)
  • Segment:offset address: A000:0000 or 9100:F000 or 9FF0:0100
There can be up to 4096 ways to specify the same address.

Calculating the linear address, you need to multiply the segment with 0x10 (16 in hex) and add the offset.


Not all memory is available for use. The restricted areas include:
Low memory (< 1MB):
0x0 - 0x3FFInterrupt vector table
0x400 - 0x4FF: Bios data area
0x7C00 - 0x7DFF: The boot sector of the kernel. You can overwrite this area if you don't need it any more.

0x9FC00 - 0x9FFFF: The extended bios data area (may start from 0x80000)
0xA0000 - 0xBFFFF: Video RAM. This is where you usually write graphics to the screen (in graphic modes), or text (in text mode). For the default text mode (0x03), the address to write to is 0xB8000.
0xC0000 - 0xFFFFF: Read only, mostly code area. Contains the Video BIOS, some mapped hardware, and the motherboard BIOS.

Upper memory (>1MB):
These areas, if exist, must be read from the multiboot information structure. More about it in the future. There is a standard memory hole between 15 and 16MB, but again, you must read the information from the multiboot information structure.


Practice: the screen

If you read carefully above, to write text to the screen you need to write to address 0xB8000. For each character, you output 2 bytes: the ASCII code, and the color.

For example, to write a colored 'A' in position (3, 10):
  • write ASCII code to 2 * (10 * ConsoleWidth + 3)
  • write color code to 2 * (10 * ConsoleWidth + 3) + 1 (high nibble is the background, low nibble is the foreground).

To clear the screen, write zeros to all the bytes. The screen size in the default text mode is 80 x 25 characters, so you need to write a total of 80 * 25 * 2 bytes. If you want to color the background when the screen is cleared, set the color property for every character to the desired color (high nibble for background, low for foreground).

All these routines are implemented and explained in the video tutorial. You can also download the project files here: http://dl.dropbox.com/u/24832466/OSDEV/MyOS-2.2.zip

OSDEV Series - Episode 2.2 - The screen

Section 2: The basics
Episode 2: The screen


Project files: http://dl.dropbox.com/u/24832466/OSDEV/MyOS-2.2.zip

Covered topics:
* Theory: we learn about memory, how it works and what it contains, and how to use it properly
* Practice: we write some very basic routines that display text to the screen.

Friday, August 26, 2011

Tibi's Line Counter v1.1

The line counter was updated, some bugs were fixed and some new features added.

Added features:
  • About window
  • Total counters are updated constantly during the calculation process
  • Context menu for the file list, with the following items:
    • Open file: opens the file in the default editor
    • Open containing folder
    • Copy selected path: copies the path of the selected item in clipboard
    • Remove: removes all the selected items from the list
    • Crop: removes all but the selected items from the list
Fixed bugs:
  • Freeze when selecting a large number of items (e.g. >1000)
  • Crash when clicking 'Calculate' with an empty list
  • 'Selected' counter doesn't reset when the list is cleared
Download:
You can download the software here (.exe, 35kb), or here (.zip, 15kb).
The source code is also available here (.zip, 135kb).

Other info:
If you would like to see screenshots, features, you can find them in the original post:
Lux Operating System: Tibi's Line Counter v1.0

Thursday, August 25, 2011

Skeduler 2.0 (Beta, discontinued)


Skeduler 2 is a great scheduling application. You want to run an application at a specific date and time? Skeduler 2 is the solution.



Features:
The application has many features:

  • Create tasks with a huge number of options

    • You can specify any task name and description to easily identify them: 
    • Launch any application or file, and also use command line arguments

    • Execute the task at a specific date and time, and repeat for a number of times at a given interval
    • Execute the task based on a daily schedule, and repeat the task ending at a specific time of day, every given interval
    • Kill the task after a specific time, using various methods (wait for process to respond, or kill it forcefully).
  • Control your tasks at any time, activate, deactivate or edit them
 

    • Save your tasks to disk, and import it on another computer

    • Save all the tasks to disk in a list, and import all of them on another computer

    • View a full log with all the important events
     
      • Close application automatically after a given interval, or at a specific time
       
      • Enable password protection, to avoid having unauthorized people exiting the application 
       

        • Show a tray icon, for quick access, and to free the taskbar
         
        • Load tasks or lists automatically at application start up


        Download location:
        You can download the application here (.exe, 4,115kb), and the source code here (.zip, 19,711kb).

        Author: Chibici Tiberiu

        Notes:
        The application is in beta stage, this means that it still has bugs, or it may malfunction.
        The application has been discontinued, if you would like to continue developing it, you can send me an email, so that updates will appear on this blog.