|
_syscall0 macro에서 나오는 inline assembly 도저히 해석 불가
kmalloc 두번째 arg
리눅스 매니아를 위한 커널 프로그래밍: 제 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
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 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
대부분(약 45%)이 드라이버 소스다. (2.4.26)
특정 아키텍쳐별로 존재하는 것 (for xxx archtecture) arch/xxx/boot, kernel, mm, lib, math-emu include/asm-xxx (symbolically linked by include/asm/) 참고자료 리눅스 커널에 대한 소개 by flyduck
|
||||