리눅스/커널2014. 3. 31. 10:14

early_param("HI_MEM", HI_MEM_Init) 

  --> __setup_param(str, fn, fn, 1) 으로 정의되어 있는데 이를 자세히 보면,

static const char __setup_str_##unique_id[] __initcost \
__aligned(1) = str; \
static struct obs_kernel_param __setup_##unique_id \
  __used __section(.init.setup)
  __attribute__((aligned((sizeof(long))))) \
  = { __setup_str_##unique_id, fn, early }


long 사이즈로 align된 .init.setp섹션에 obs_kernel_param 구조체 형태의 __setup_##unique_id 안에 { __setup_str_##unique_id, fn, early } 형태로 초기화 시킨다. 


obs_kernel_param 구조체는 

const char *str
int (*setup_func)(char *);
int early;

로 구성되어 있다.

이렇게 설정된 early_param의 내용은 init/main.c에서 parse_early_options() --> parse_args("early options", cmdline, NULL, 0, do_early_param) --> parse_one()안에서
return handle_unknown에서 do_early_param이 실행된다.

do_early_param을 실행시킬 때, 그동안 쌓인 obs_kernel_param 리스트(?)들을 순회하면서 실행 시킨다.(섹션에 구조체가 리스트로 들어가기 보다는 각각의 구조체가 엔트리로 들어가는 거 같은데 좀 더 확인이 필요하다.)


__setup_start[] 와 __setup_end[]는 include/asm-generic/vmlinux.lds.h 에서 다음과 같이 정의되어 있다.


#define INIT_SETUP(initsetup_align) \ . = ALIGN(initsetup_align); \ VMLINUX_SYMBOL(__setup_start) = .; \ *(.init.setup) \ VMLINUX_SYMBOL(__setup_end) = .;

또한 INIT_SETUP은 arch/arm/kernel/vmlinux.lds.S에서 16byte(?)으로 align되어 있다.

.init.data : { #ifndef CONFIG_XIP_KERNEL INIT_DATA #endif INIT_SETUP(16) INIT_CALLS CON_INITCALL SECURITY_INITCALL INIT_RAM_FS }


좀 더 자세히 봐야 하는데, 결국 맨 위, "HI_MEM"이라는 parameter에 대한 처리를 HI_MEM_init에서 처리할 수 있게 된다.


'리눅스 > 커널' 카테고리의 다른 글

Machine 이름 바꾸기  (0) 2014.04.03
Machine 이름 알아내기  (0) 2014.04.03
/dev/tty 와 /dev/console의 차이점  (0) 2014.02.05
FrameBuffer size 구하기  (0) 2013.12.11
[커널] FB 문서  (0) 2013.12.09
Posted by code cat
리눅스2014. 3. 14. 08:44


--sysroot=dir
Use dir as the logical root directory for headers and libraries. For example, if the compiler normally searches for headers in /usr/include and libraries in /usr/lib, it instead searches dir/usr/include and dir/usr/lib.

If you use both this option and the -isysroot option, then the --sysroot option applies to libraries, but the -isysroot option applies to header files.

The GNU linker (beginning with version 2.16) has the necessary support for this option. If your linker does not support this option, the header file aspect of --sysroot still works, but the library aspect does not. 


sysroot 는 컴파일 시에 필요한 header/lib 들을 찾는 경로에 대한 베이스 경로를 지정해 줄 수 있다.

여러가지 용도로 사용할 수 있겠으나, 다음과 같은 경우에 우선 쓸 수 있다.

1. gdb 로 디버깅 시, 타깃머신(gdbserver가 동작중)의 라이브러리들이 소스머신(gdb 동작중)의 라이브러리들과 매칭이 되지 않을 때.

2. toolchain이 소스와 제공(android경우)되어 그 toolchain을 써야 하나, bionic libc에서 지원하지 않는 라이브러리 함수를 어플리케이션이 사용해야 할 때.


위의 노란 부분은 gcc에서 sysroot 사용법에 대한 설명이다.  --sysroot=dir을 설정하면, 컴파일러께서는 dir/usr/include, dir/usr/lib 등으로 찾으신다.

Posted by code cat
프로그래밍/C++2014. 2. 19. 08:51

jump to case label -fpermissive


라고 나오는 에러는 흔히 switch-case문에서 case안에서 변수 선언 & 초기화를 할 때 나올 수 있는 문제이다.  이는 언어에서 정한 standard를 벗어난 경우이며, -fpermissive를 써서 호환가능하게 해 줄 수는 있지만, 쓰지 말고, 코드를 fix하는 방향으로 가도록 하자.


'프로그래밍 > C++' 카테고리의 다른 글

[c++] UML autogenerator  (2) 2015.03.23
생성자 호출 방법  (0) 2015.03.19
[template]템플릿 예제  (0) 2013.08.04
null pointer vs stray pointer  (0) 2013.05.26
[c++] malloc/free 대신 new/delete을 쓰는 이유?  (0) 2013.05.18
Posted by code cat
$ screen -X -S [session # you want to kill] quit


Posted by code cat
리눅스/커널2014. 2. 5. 11:44

출처:http://chaoxifer-univ.blogspot.kr/2010/10/devtty-devconsole.html


/dev/tty 와 /dev/console의 차이점


There is a subtle difference between the console and the terminal. In a windowed environment, a tty terminal is associated with each shell session; in other words, each command line window such as an xterm is a separate terminal. Redirection to /dev/tty sends output to the active window. The console, on the other hand, is the screen. It is the monitor in general. Most windowing programs provide a special switch to the shell windows that will link /dev/console to the window instead of writing output directly on the screen. In any event, output can be redirected to these devices quite easily.



출처:http://unix.stackexchange.com/questions/60641/linux-difference-between-dev-console-dev-tty-and-dev-tty0


From the documentation:

/dev/tty        Current TTY device
/dev/console    System console
/dev/tty0       Current virtual console

In the good old days /dev/console was System Administrator console. And TTYs were users' serial devices attached to a server. Now /dev/console and /dev/tty0 represent current display and usually are the same. You can override it for example by adding console=ttyS0 to grub.conf. After that your /dev/tty0 is a monitor and /dev/console is /dev/ttyS0.

An exercise to show the difference between /dev/tty and /dev/tty0:

Switch to the 2nd console by pressing Ctrl+Alt+F2. Login as root. Type sleep 5; echo tty0 > /dev/tty0. Press Enter and switch to the 3rd console by pressing Alt+F3. Now switch back to the 2nd console by pressing Alt+F2. Type sleep 5; echo tty > /dev/tty, press Enter and switch to the 3rd console.

You can see that tty is the console where process starts, and tty0 is a always current console.




  • /dev/console is a virtual set of devices which can be set as a parameter at boot time. It might be redirected to a serial device or a virtual console and by default points to /dev/tty0. When multiple console= options are passed to the kernel, the console output will go to more than one device.

  • /dev/tty0 is the current virtual console

  • /dev/tty[1-x] is one of the virtual consoles you switch to with control-alt-F1 and so on.

  • /dev/tty is the console used by the process querying it. Unlike the other devices, you do not need root privileges to write to it. Note also that processes like the ones launched by cron and similar batch processes have no usable /dev/tty, as they aren't associated with any. These processes have a ? in the TTY column of ps -ef output.


'리눅스 > 커널' 카테고리의 다른 글

Machine 이름 알아내기  (0) 2014.04.03
early_param에 대해  (0) 2014.03.31
FrameBuffer size 구하기  (0) 2013.12.11
[커널] FB 문서  (0) 2013.12.09
[안드로이드][커널]Unknown symbol _GLOBAL_OFFSET_TABLE_  (0) 2013.08.09
Posted by code cat