alpaca2unix blog

UNIXやGnu/Linuxの勉強と備忘録です。

Makefileなんて書いてられない・・・CMakeでいってみる

Makefaileの書き方すらままならない超初心者がOSを作っているのですが、GNUのサイトに行って、bootloaderのMakefileを研究してたんです。

その結果、Makefileの良さは理解できるものの、これを毎回、書くの?とげんなりしたことです。どんだけ長いんだよ。

それでも、Makefileを書けるようにならないと、作業は完全にままならないわけで、どうにかこうにか、ネットで調べ物をしていました。

そうすると、CMakeというのがあるとのこと。おんや?

Makefileを吐き出してくれると言うではないですか!

はじめは、Linuxには、CMakeはないのかしら?と思っていたのですが

$ apt-cache search CMakeとしたら、

ちゃんとありました。苦笑

ためしに、hello world! を書いてCMakeをすると、確かにMakefileが吐き出されました。それも、やたらと詳しく書き出してある。

とりあえず、いまは、CMakeを使って作業をしてみたいと思います。CMakeはCMakeでいろいろ文法とかあるようなので、勉強は必要ですが。

じかに、Makefileを書くよりかは楽かなと思いました。

だって、今回、OSのソースができているのに、Makefileの書き方が分からなくてつまづいていたのですから・・・^ ^;;

 

f:id:alpaca2unix:20170322210856p:plain

 

ついでに、Visual Studio Codeもダウンロードしといたわ。笑

Linuxとか、Unix系は難しい。そこがまた、おもしろいんだけど、ちょっとやりたいことができると背に腹は変えられないような気がしてきたわ・・・

 

kayo .~*

Emacsのewwブラウザは使える!

テキストブラウザで、links2を気に入って使用していたのですが、ふと、Emacsw3mはどんな感じかしら?と調べているうちに、現在のEmacsには

「EWW = Emacs Web Wowser」というブラウザが内臓されているというではありませんか。早速、使ってみたらとってもハマりました。^ ^*

f:id:alpaca2unix:20170320144339p:plain

素早く表示できるし、links2だと画像は表示できなかったけれど、ewwは表示できちゃうのです。

あと、Emacsの特性上、Webをしながらメモを取るということができます。これは使うしない!^ ^*

わたしが参考にした、ewwの記事を下に載せておきます。

mag.osdn.jpEWWの使い方 [QumaWiki]

http://suzuki.tdiary.net/20140807.html

futurismo.biz

No.1) 英語はmust!! 今日読んだ英語のscripts!!

/*

www.gnu.org*/

4.2 BIOS device mapping techniques

Both of these techniques should be usable from any PC operating system, and neither require any special support in the drivers themselves. This section will be flushed out into detailed explanations, particularly for the I/O restriction technique.

The general rule is that the data comparison technique is the quick and dirty solution. It works most of the time, but doesn't cover all the bases, and is relatively simple.

The I/O restriction technique is much more complex, but it has potential to solve the problem under all conditions, plus allow access of the remaining bios devices when not all of them have operating system drivers.

/*

www.gnu.org*/

4.2.2 I/O restriction technique

This first step may be unnecessary, but first create copy-on-write mappings for the device drivers writing into pc ram. Keep the original copies for the clean bios virtual machine to be created later.

For each device driver brought online, determine which bios devices become inaccessible by:

  1. Create a clean bios virtual machine.
  2. Set the I/O permission map for the I/O area claimed by the device driver to no permissions (neither read nor write).
  3. Access each device.
  4. Record which devices succeed, and those which try to access the restricted I/O areas (hopefully, this will be an xor situation).

For each device driver, given how many of the bios devices were subsumed by it (there should be no gaps in this list), it should be easy to determine which devices on the controller these are.

In general, you have at most 2 disks from each controller given bios numbers, but they pretty much always count from the lowest logically numbered devices on the controller.

 

/*

www.gnu.org*/

 

4.3 Example OS code

In this distribution, the example Multiboot kernel kernel is included. The kernel just prints out the Multiboot information structure on the screen, so you can make use of the kernel to test a Multiboot-compliant boot loader and for reference to how to implement a Multiboot kernel. The source files can be found under the directory doc in the Multiboot source distribution.

The kernel kernel consists of only three files: boot.S, kernel.c and multiboot.h. The assembly source boot.S is written in GAS (see GNU assembler), and contains the Multiboot information structure to comply with the specification. When a Multiboot-compliant boot loader loads and execute it, it initialize the stack pointer and EFLAGS, and then call the function cmain defined in kernel.c. If cmain returns to the callee, then it shows a message to inform the user of the halt state and stops forever until you push the reset key. The file kernel.c contains the function cmain, which checks if the magic number passed by the boot loader is valid and so on, and some functions to print messages on the screen. The file multiboot.h defines some macros, such as the magic number for the Multiboot header, the Multiboot header structure and the Multiboot information structure.

 

kayo .~*

/etc/fstabがrootでも編集できない場合

ファイルのパーミッションを見る限り、rootだと読み書きできる・・・はずなのに、何らかの事情で読み込み専用です。といって、書き込みを受け付けなくなるときがあります。このような現象に出会った場合、次のコマンドを打てば解決できます。

mount -o remount ,rw /

 あとは、fstabをいつものように編集してみて下さい。

 

kayo .~*

lm_sensorsでOverClocking (linux)


how to: lm-sensors great for overclocking in linux

 

この動画の通りにすると、簡単にできました。

オーバークロックだけではなく、様々なコマンドが使えて楽しかったです。

「lm_sensors」なかなか便利です。

使い方の詳細は、Arch Linux のページが優秀です。

https://wiki.archlinuxjp.org/index.php/Lm_sensors

 


Linux Tip - CPU Frequency Scaling

 

また、このおにーさんも詳しく解説しています。ただ、カーネルの設定で、同じようなことができたはずなので、lm_sensorsを使うのがよいのか、Kernelをre-buildするのが良いのか、どちらなんだろうと思います。

 

kayo .~*