1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

自作OS紹介

1
Last updated at Posted at 2026-10-07

紹介

年始に32ビットx86向けのOSを作っていましたが、途中で嫌になりやめていました。
ここ数日又やる気が出てきたので再開しています。

簡単なCUIのOSで、実行ファイルが起動できます。

GITHUBから落として、Linux上で./buiil.shと実行すると起動するようにしています。gcc,nasm,qemuが必要です。
Makefileはどうしても好きになれないので使用していません。

実機でも起動はするのですが、ATAドライバしか作っておらず、ディスク読み込みが出来ないので使い物になりません。
USBドライバを作りたいのですが何度挑戦してもPCIからUSBを見つけるところまで辿り着けず、実装できずにいます。

图片.png

システムコールは作りましたが権限はまだ分けておらず、ページングも実装していない為、全て物理アドレスです。
今後分けようと今勉強しています。

ユーザ側からは今のところ画面表示、ファイル読み込み、ヒープの申請くらいができます。

プロセスはまだ複数実行できません。権限や仮想メモリを実装した後に考えます。

cat.c
#include "lib/mystdio.h"
#include "lib/stdint.h"

int main(int argc, char **argv){ 

    if(argc < 2){
        write("Usage: cat <filename>\n");
        return -1;
    }  
    
    uint8_t buf[4096];

    // ファイルを開く
    int fd = open(argv[1]);
    if(fd < 0){
        write("open error\n");
        return -1;
    }

    // 読み込み
    int n = read(fd, buf, sizeof(buf));
    if(n < 0){
        write("read error\n");
        close(fd);
        return -1;
    }

    // 表示
    write((char*)buf);

    // 閉じる
    close(fd);

    return 0;
}
memtest.c
#include "lib/mystdio.h"

int main(int argc, char **argv) {
    char* msg = (char*)malloc(64);
    if (msg) {
        printf_x("malloc succeeded! addr=%x\n", (unsigned int)msg);
        free(msg);
    }
    return 0;
}
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?