selanac82
selanac82

Reputation: 3000

Bootable program

I'm a front end developer that's looking to get into some other languages such as Java or C++. I have an idea for a program and was just looking for an answer to something. What I would like to do is build a program and boot directly to that program. For example I have an old computer and I wipe the hard drive clean. So they is nothing currently on it. Not even an OS. I want to build a program that I can install to the hard drive that will boot straight into the program once started. Would this be considered an OS?

Upvotes: 2

Views: 2778

Answers (6)

SliceSort
SliceSort

Reputation: 375

Java can't run without Environment. If you want to run you program on you machine without OS, Java is a wrong choice. C++ program can run without OS, but it's difficult to write a bootable program in C++. If you want to write your own bootable program, you should use assembly for boot and load function, with some knowledge to use hardware in low level.

Upvotes: 1

deeiip
deeiip

Reputation: 3379

First of all you need to decide your your program needs what. I mean should operate in Protected mode or the routine you have is tiny, so it is enough to run before entering protected mode (i.e. in real mode).

Here you can do three things

  1. Modify bootloader to jump the execution to your code . Then Your code can resume normal os initialization.
  2. Modify your os kernel early initialization code So that it executes your code before entering protected mode

  3. I think your code will not be harmed if a bit of os portion is running. So you can write your routine before full kernel initialization.

    Now note that for the later two point you need to modify your kernel, which is not easy (not even always possible)

    Now the problem in first approach: Nothing will be ready for you, not even a regular c library or divice drivers , so you have to write every raw bit of code by hand which is crude.


This is off course not possible in java. Because the jvm will not be ready for you.

Booting Stages


Now practically: there are lot of tiny os available, use one of them and modify as per your need. use this link to get a complete list of what is available for you.

Upvotes: 2

Keith Irwin
Keith Irwin

Reputation: 5668

First, Java is right out. You cannot possibly do this in Java without enormous amounts of tool-building. Java is not suited for this task at all.

You can do it in C++ or C. The search terms you are looking for is operating system development. This would probably not technically be considered developing an Operating System since it wouldn't run other programs, but the information about how to get through the boot-up procedure and establish a minimal environment are going to be most easily found in the category of operating system development. Some reasonable starting resources for that can be found at the OS Dev Wiki.

Alternately, you could take an existing small open-source OS and modify what it does after the boot-up sequence completes. If your program is intending to do anything more than just use the keyboard and the screen in text mode, there need to be device drivers. Thus, depending on the project, changing an existing OS may be the easiest route because you won't need to write your own device drivers for any devices you want to use.

Upvotes: 1

Elliott Frisch
Elliott Frisch

Reputation: 201537

Unless you want write something in (for example) Open Firmware and Forth or say a ROM BASIC. You'll probably qualify as a boot loader. Your application may qualify as an operating system. In my opinion, and a modern context, it entirely depends on how much functionality it provides to hosted applications. I'm not sure that something like FreeDOS would be considered an operating system (no pre-emptive task scheduling or GUI for example) given modern computers (I don't care to argue the point either way).

Upvotes: 0

MTilsted
MTilsted

Reputation: 5518

No you don't. Unless you want to spend many years, writing drivers for your graphics card, harddisk controller, usb controller, dma controller and all the other hardware your computer have.

What you want is a minimal operation system, which include just the kernel, and a runtime library and which start your program and nothing else on startup. A minimal Linux such as linux from scratch or bsd would be a good starting point.

Upvotes: 2

Sean
Sean

Reputation: 179

You have to have an operating system, so your program would be the operating system (or you would have to use another one and write it for that). It's certainly possible in C++, but it's not really possible to write an operating system in java.

Upvotes: 0

Related Questions