Kernel: 모르겠는거, 공부할것
_syscall0 macro에서 나오는 inline assembly 도저히 해석 불가
kmalloc 두번째 arg
by jungjoon | 2004/11/25 03:32 | kernel/tmp | 트랙백 | 덧글(4)
제 4장. 시스템 콜
리눅스 매니아를 위한 커널 프로그래밍: 제 4장 시스템 호출 구현

Device - PIC - CPU의 연결

IDT: interrupt descriptor table (number to handler)
0x0 ~ : trap handler (Exception: process가 발생하는 trap, interrupt)
0x20 ~ : device interrupt handler (IRQ)
0x80 : system call trap

시스템 호출 추가:
include/asm-i386/unistd.h 수정 // system call의 내부 번호 정의
arch/i386/kernel/entry.S // call entry point
아무데나 새로운 시스템 콜 구현(implementation)

macros:
include/asm/unistd.h/_syscall0(,,) // 유저레벨에서 시스템 콜을 호출하는(int 0x80) in-line assembly 생성, eax에 call number 등등...
include/asm/uaccess.h/put_user(*, ) // 유저레벨의 메모리에 쓰기를 수행

global variables:
struct task_struct *current; // 현재 수행중인 process
struct task_struct *init_task; // init process, process list의 시작, 끝은 다시 init_task로 연결

functions:
kmalloc(size, opt); // malloc in kernel mode
by jungjoon | 2004/11/25 03:26 | kernel/log | 트랙백(2) | 덧글(0)
메모리 관리
1장. 하드웨어의 기초 from 'The linux kernel'
리눅스 커널은 매우 잘 레이어링 되어있다.
2장. 소프트웨어의 기초 from 'The linux kernel'
virtual page number, physical page number간 주소변환, PTE(page table entry)등은 모두 프로세서가 하드웨어적으로 관리한다. PTE에는 엔트리의 유효여부(메모리에 있는지 올바른지), 각종 Access control bit, dirty bit, physical page number등이 들어 있다.
page fault가 발생하면, kernel은 해당 page가, demand paging으로 로딩 안된 프로그램 이미지를 가지는 page인지, 스왑아웃된 page인지 구별해야 한다. 이는 PTE를 봄으로써 가능하다. 즉, PTE가 유효하지 않지만, 비어있지 않다면(주소가) 스왑아웃된 page이고(그러므로 스왑파일에서 읽어서 로딩), 유효하지 않고 비어 있다면 아직 로딩안된 프로그램 이미지 page이다.

term
BSS: block started by symbol, 초기화 되지 않은 global data 공간
HTA: h/w address translation
= MMU: momory management unit

structs
include/linux/sched.h/task_struct : info of a process (runtime)
include/linux/sched.h/mm_struct : info of a process's mem state
mmap: va_area_struct(for a segment) list
pgd: page directory addr (run되면 CR3 reg로 카피, un-run되면 CR3 reg에서 복사)
start_(code|data|stack) 각 segment의 시작주소
stack, heap 등의 runtime 정보 (크기, 등)
include/linux/mm.h/vm_area_struct info of a segment(code, data, stack, ..)
vm_(start,end): segment의 시작과 끝
vm_file: runtime executables, library file의 이름
vm_offset: vm_file의 어느 부분이 시작점인지
vm_file, vm_offset=> page fault시 로드할 곳 결정

참고자료.
The linux kernel 번역본
'리눅스 매니아를 위한 커널 프로그래밍'
by jungjoon | 2004/11/17 22:38 | kernel/log | 트랙백 | 덧글(0)
boot image의 root partion과 그 외 옵션 지정
리눅스 커널에 대한 소개 by flyduck에서...

man: rdev - query/set image root device, RAM disk size, or video mode

dd if=bzImage of=/dev/fd0
rdev -R /dev/fd0 /dev/hda1
by jungjoon | 2004/11/15 02:20 | linux/tip | 트랙백(1) | 덧글(2)
리눅스 소스의 대략적인 레이아웃
대부분(약 45%)이 드라이버 소스다. (2.4.26)

jjkim@colinux linux $ du --max-depth=1 -m
1 ./crypto // crypt algorithms
22 ./fs
1 ./init // booting system
1 ./kernel // kernel core
1 ./lib // lib. kernel doesn't use one of standard C
1 ./mm // memory management system
33 ./include
./include/linux // arch. 독립적인 header
12 ./net
1 ./ipc
92 ./drivers
38 ./arch
1 ./scripts
7 ./Documentation
209 .


특정 아키텍쳐별로 존재하는 것 (for xxx archtecture)
arch/xxx/boot, kernel, mm, lib, math-emu
include/asm-xxx (symbolically linked by include/asm/)

참고자료 리눅스 커널에 대한 소개 by flyduck
by jungjoon | 2004/11/15 02:06 | kernel/log | 트랙백 | 덧글(3)
< 이전페이지 다음페이지 >