출처: 인사이드 안드로이드(위키북스출판)

RPC code & RPC data
서비스 클라이언트는 서비스서버에 존재하는 서비스의 함수를 사용하기 위해,
각 함수에 해당하는 식별자를 바인더 IPC데이터에 담아 전달 <-- RPC 코드
함수의 인자 역시 IPC데이터에 담아 전달                           <-- RPC 데이터

즉, 서비스 서버가 가진 서비스의 함수를 호출할려면, PRC코드를 알아야 함.

바인더 어드레싱
context manager : 다양한 서비를 모두 목록화해서 관리함.  서비스마다 핸들(바인더 IPC의 목적지 주소로 사용)이라는 번호값을 할당. 서비스의 추가/검색등의 관리기능을 수행.  %context manager의 핸들값은 0으로 지정되어 있음
바인더 드라이버는 IPC 데이터의 핸들을 가지고 서비스 서버를 찾는데, 이러한 과정을 바인더 어드레싱이라 함.

바인더 어드레싱을 위해 서비스 서버는 자신이 가진 서비스에 대한 접근 정보를 컨텍스트 매니저에 등록해야함.
서비스서버는 ADD_SERVICE라는 RPC코드와 등록할 서비스 이름(RPC데이터), 그리고 핸들을 0으로 지정하고IPC데이터에 실어 바인더 드라이버에 전달함.
바인더 드라이버는 먼저 핸들 0에 해당하는 바인더 노드를 찾음. 핸들 0에 해당하는 바인더 노드를 context manager를 의미하기 때문에 서비스 서버는 IPC데이터를 context manager에 전달함.
이후 바인더 드라이버는 서비스서버의 서비스 A에 해당하는 바인더 노드를 하나 생성함.  그리고 contenxt manager가 생성된 바인더 노드를 알수 있게 바인더 노드 참조 데이터를 생성해 해당 노드를 연결함.
참조 데이터는 생성된 순서대로 번호가 매겨지고, 이 번호는 ipc데이터에 담겨 context manger로 전달됨
context manager는 ipc데이터에 들어있는 서비스 이름과 바인더 노드의 번호를 서비스 리스트에 등록.

 %바인더 노드는 바인더 드라이버내 자료구조이며, 서비스마다 하나씩 존재함. 그리고 프로세스마다 바인더 노드들을 리스트로 가진다.(바인더 노드는 ipc의 대상이 되는 프로세스를 찾기 위한 식별자 정도로 이해하면 됨)

프로세스 관점에서의 서비스 사용
클라이언트던 서버 입장이던 다음과 같은 공통 작업을 거친다.
1. 바인더 드라이버 열기 open()함수 호출
2. IPC 데이터/응답 데이터 수신 버퍼 확보 mmap()함수 호출
3. 데이터 송신을 위한 ioctl()함수 호출

바인더 드라이버 관점에서의 서비스 사용
...

'안드로이드 > 프레임워크' 카테고리의 다른 글

Bionic libc (2)  (0) 2012.11.08
Bionic libc  (0) 2012.10.30
안드로이드 init.rc (oom_adj값)  (0) 2012.09.27
Dalvik Virtual Machine 와 odex  (0) 2012.08.13
안드로이드 프레임워크 *Java에서 전처리기 사용하기*  (0) 2011.06.06
Posted by code cat
프로그래밍/C2011. 10. 23. 14:51
구조체 멤버로 주소를 저장하기 위해서는 구조체 멤버를 포인터 변수로 선언하라
구조체 멤버로 연속적인 메모리를 만들기 위해서는 구조체 멤버를 배열로 선언하라
 

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

process & signal  (0) 2012.01.25
error: invalide storage class for function 'xxxx'  (0) 2011.11.29
대상체의 기억수명  (0) 2011.11.29
열거, enum, 이놈  (0) 2011.11.28
전처리기 (1)  (0) 2011.11.09
Posted by code cat
프로그래밍/JAVA2011. 10. 19. 10:11

거의 십중팔구 jdk가 제대로 안 깔려서 이다.

이걸 확인할려면, javac를 입력해보면 없을 경우, 다음과 같은 패키지에서 어쩌구저쩌구 한다.
그중 openjdk-6을 골라서 sudo apt-get install openjdk-6을 설치 해 준다.

이젠 ant로 잘 빌드가 될 것이다.

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

OTA Package Utility  (0) 2013.11.25
Swing desiginer LookAndFeel 종류  (0) 2013.11.19
Java Generics  (0) 2012.10.01
WindowBuilder Pro for Eclipse 3.7(Indigo) 설치 오류  (0) 2012.08.06
Posted by code cat
리눅스/커널2011. 9. 25. 14:47
1 Booting ARM Linux
2 =================
3
4 Author: Russell King
5 Date : 18 May 2002
6
7 The following documentation is relevant to 2.4.18-rmk6 and beyond.
8
9 In order to boot ARM Linux, you require a boot loader, which is a small
10 program that runs before the main kernel. The boot loader is expected
11 to initialise various devices, and eventually call the Linux kernel,
12 passing information to the kernel.
13
14 Essentially, the boot loader should provide (as a minimum) the
15 following:
16
17 1. Setup and initialise the RAM.
18 2. Initialise one serial port.
19 3. Detect the machine type.
20 4. Setup the kernel tagged list.
21 5. Call the kernel image.
22
23
24 1. Setup and initialise RAM
25 ---------------------------
26
27 Existing boot loaders: MANDATORY
28 New boot loaders: MANDATORY
29
30 The boot loader is expected to find and initialise all RAM that the
31 kernel will use for volatile data storage in the system. It performs
32 this in a machine dependent manner. (It may use internal algorithms
33 to automatically locate and size all RAM, or it may use knowledge of
34 the RAM in the machine, or any other method the boot loader designer
35 sees fit.)
36
37
38 2. Initialise one serial port
39 -----------------------------
40
41 Existing boot loaders: OPTIONAL, RECOMMENDED
42 New boot loaders: OPTIONAL, RECOMMENDED
43
44 The boot loader should initialise and enable one serial port on the
45 target. This allows the kernel serial driver to automatically detect
46 which serial port it should use for the kernel console (generally
47 used for debugging purposes, or communication with the target.)
48
49 As an alternative, the boot loader can pass the relevant 'console='
50 option to the kernel via the tagged lists specifying the port, and
51 serial format options as described in
52
53 Documentation/kernel-parameters.txt.
54
55
56 3. Detect the machine type
57 --------------------------
58
59 Existing boot loaders: OPTIONAL
60 New boot loaders: MANDATORY
61
62 The boot loader should detect the machine type its running on by some
63 method. Whether this is a hard coded value or some algorithm that
64 looks at the connected hardware is beyond the scope of this document.
65 The boot loader must ultimately be able to provide a MACH_TYPE_xxx
66 value to the kernel. (see linux/arch/arm/tools/mach-types).
67
68
69 4. Setup the kernel tagged list
70 -------------------------------
71
72 Existing boot loaders: OPTIONAL, HIGHLY RECOMMENDED
73 New boot loaders: MANDATORY
74
75 The boot loader must create and initialise the kernel tagged list.
76 A valid tagged list starts with ATAG_CORE and ends with ATAG_NONE.
77 The ATAG_CORE tag may or may not be empty. An empty ATAG_CORE tag
78 has the size field set to '2' (0x00000002). The ATAG_NONE must set
79 the size field to zero.
80
81 Any number of tags can be placed in the list. It is undefined
82 whether a repeated tag appends to the information carried by the
83 previous tag, or whether it replaces the information in its
84 entirety; some tags behave as the former, others the latter.
85
86 The boot loader must pass at a minimum the size and location of
87 the system memory, and root filesystem location. Therefore, the
88 minimum tagged list should look:
89
90 +-----------+
91 base -> | ATAG_CORE | |
92 +-----------+ |
93 | ATAG_MEM | | increasing address
94 +-----------+ |
95 | ATAG_NONE | |
96 +-----------+ v
97
98 The tagged list should be stored in system RAM.
99
100 The tagged list must be placed in a region of memory where neither
101 the kernel decompressor nor initrd 'bootp' program will overwrite
102 it. The recommended placement is in the first 16KiB of RAM.
103
104 5. Calling the kernel image
105 ---------------------------
106
107 Existing boot loaders: MANDATORY
108 New boot loaders: MANDATORY
109
110 There are two options for calling the kernel zImage. If the zImage
111 is stored in flash, and is linked correctly to be run from flash,
112 then it is legal for the boot loader to call the zImage in flash
113 directly.
114
115 The zImage may also be placed in system RAM (at any location) and
116 called there. Note that the kernel uses 16K of RAM below the image
117 to store page tables. The recommended placement is 32KiB into RAM.
118
119 In either case, the following conditions must be met:
120
121 - Quiesce all DMA capable devices so that memory does not get
122 corrupted by bogus network packets or disk data. This will save
123 you many hours of debug.
124
125 - CPU register settings
126 r0 = 0,
127 r1 = machine type number discovered in (3) above.
128 r2 = physical address of tagged list in system RAM.
129
130 - CPU mode
131 All forms of interrupts must be disabled (IRQs and FIQs)
132 The CPU must be in SVC mode. (A special exception exists for Angel)
133
134 - Caches, MMUs
135 The MMU must be off.
136 Instruction cache may be on or off.
137 Data cache must be off.
138
139 - The boot loader is expected to call the kernel image by jumping
140 directly to the first instruction of the kernel image.

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

Virtual Linux Manager 정리 1  (0) 2012.03.18
GCC, typeof  (0) 2012.02.23
Linux 3.0 Kernel  (0) 2011.07.31
커널선점  (0) 2011.05.01
커널 스레드  (0) 2011.05.01
Posted by code cat
시스템 시간이 다른 머신 사이에서 tar로 압축해서 파일을 옮길때,
tar: 파일 어쩌구저쩌구.c  time stamp 날짜 시간 s in the future 이런 식으로 메세지가 뜨면은

파일을 풀 때, m 옵션을 넣어주면 된다.  man tar를 보면, m옵션에 대해서 다음과 같이 기재되어 있다.

-m, --touch, --modification-time 
don't extract file modified time

 

즉 변환된 시간을 넣지 말라는 소리다.

그러므로,
tar xvfz archive.tar.gz

대신
tar xmvfz archive.tar.gz

하면 된다. 


Posted by code cat
리눅스2011. 8. 17. 14:21
출처: http://www.novell.com/support/search.do?cmd=displayKC&sliceId=SAL_Public&externalId=3907838
 

JBD: barrier-based sync failed on mmcblkxxx -diabling barriers

JBD = 저널링 블록 디바이스
이 메세지를 끌라면, barrier=off 라는 매게변수를 커널에 넘겨주면 된다. GRUB의 경우에는 /boot/grub/menu.lst에 넣으면 되겠다.  이렇게 하면 커널은 transaction barrier 메카니즘을 사용하지 않게된다.

기본적으로 리눅스 커널은 transaction barrier를 사용하는데, 이는 데이터의 보전성을 유지하기 위한 부가적인 메카니즘이다.
많은 저장 서브시스템은 data의 write 퍼포먼스를 높이기 위해 캐시나 쓰는 order를 변경하는데, 이는 저널링 파일 시스템안에서 관리되는 저널된 데이터에겐 좋지 않다.  저널링은 실제 데이터가 쓰여지기 전에 메타데이터를 씀으로서 크래시 리커버리를 구현한다.  위의 에러(?) 메세지는 그러한 transaction barrier를 지원하지 않는다는 소리이며, 전혀 해로울것은 없지만, barrier는 일반적으로 퍼포먼스를 높여준다.

Posted by code cat
리눅스2011. 8. 2. 20:39
dd if=/dev/zero of=ext4.img bs=1MB count=20  // 20mb 짜리 ext4.img라는 파일을 생성

mke2fs -T ext4 ext4.img  //ext4 타입으로 ext4.img를 포맷


mkdir test //테스트용 디렉토리 생성(마운트 포인트로 이용)

mount -t ext4 -o loop ext4.img test/   //마운트

마운트가 성공됬으면(mount 커맨드로 확인), 테스트로 파일을 막 써보자.
cd test
touch TEMPFILE
mkdir BABO
...

파일이 제대로 생성됐는지 확인해보고, 언마운트를 해보자
cd ..  //test 폴더 안에서 언마운트 할라면 device busy라고 불평한다.
umount /dev/loop0  //꼭 loop0이라는 보장은 없고 아마 마운트시 available한 loop이 잡히는 걸로 안다.
                             //이 부분은 losetup으로 체크할 수 있는 걸로 안다.
cd test/
ls -al 로 확인하면 텅 빈 걸 확인할 수 있다.

다시 마운트 해보자.
mount -t ext4 -o loop ext4.img test/ 
ls -al
해보면 아까 테스트로 막 만든 파일들이 보인다.

자 그럼 이걸 가지고 뭐에 써먹냐 ?  ext4.img 자체를 파티션에 그대로 구울 경우, ext4파일 시스템을 가진 루트파일 시스템 등을 구축 할 수 있는 것이다.  EXT4f라고 썼지만 다른 파일 시스템도 이렇게 해서 굽는게 가능하다.  물론 안드로이드용 파일 시스템을 만들 땐 이걸 안 썼다. 언제 저 짓해서 맨날 구워줄 수 있단 말인가?  다른 방법에 대해서는 다음 기회에~
Posted by code cat

dd if=/dev/zero of=ext3.image bs=1MB count=1024

포맷에 따라서 파일을 복사하거나 변환시킴(주로 빈 파일 만들거나, loopback 디바이스 만들 때 사이즈 할당 시켜서 파일 만들 때 씀)

if=FILE
표준 입력 대신 파일로부터 읽어들인 파일
of=FILE
표준아웃으로 대신 파일로 씀
bs=BYTES
          ibs랑 obs를 BYTES로 강제 설정
count=BLOCKS
BLOCKS 만큼의 입력 블록을 복사함.

더 많은 정보는 http://linux.die.net/man/1/dd

 

'리눅스 > 스크립트/유틸' 카테고리의 다른 글

우분투 사용자 추가  (0) 2012.02.24
tar: time stamp s in the future  (0) 2011.08.26
tee 커맨드  (0) 2011.06.19
엔디안 처리하는 함수  (0) 2011.06.06
busybox cross-compile  (0) 2011.06.01
Posted by code cat
리눅스/커널2011. 7. 31. 15:07

툴체인 설치 하고 커널 컴파일 준비 끝!

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

GCC, typeof  (0) 2012.02.23
Documentation/arm/booting  (0) 2011.09.25
커널선점  (0) 2011.05.01
커널 스레드  (0) 2011.05.01
커널 초기화  (0) 2011.04.20
Posted by code cat
프로그래밍2011. 7. 8. 14:16

출처:http://redstack.net/blog/2008/01/16/x86-calling-conventions/

x86 calling conventions

This is the first article of a (I hope) long series of articles about ‘The Basics: What everyone should know about’ :)

The calling convention defines the way a function or a piece of code should arrange data before calling a function, and what to do after. It responds to questions like “In which order should I pass the arguments ?”“Should I clean something ?”“Where is the result ?”, …

There is a lot of different calling conventions. Here are the 3 I see the most of the time:

  • cdecl
  • stdcall
  • fastcall

cdecl convention

The cdecl convention is the default one used when working with a C compiler like GCC or MSVC. To use the cdecl scheme for a function, you can use this syntax (GCC):

__attribute__((cdecl)) int function(int arg1, int arg2, ...);

GCC will produce the following code when calling a cdecl function with 4 arguments :

push   0x4 ; arg4
push   0x3 ; arg3
push   0x2 ; arg2
push   0x1 ; arg1
call   _cdecl_fct
add    esp,0x10
mov    DWORD PTR [ebp-0x4],eax

As you can see, arguments are pushed into the stack in right to left order, and it’s up to the caller to remove the arguments from the stack (Here this is done by add esp, 0x10). The result of the function is stored in the EAX register.

stdcall convention

The stdcall convention is the one used by Win32 APIs. It’s also the easyest to use when writing ASM code, in my opinion. A function can be declared as a stdcall function in C with this syntax (GCC):

__attribute__((stdcall)) int function(int arg1, int arg2, ...);

GCC will produce the following code when calling a stdcall function with 4 arguments :

push   0x4 ; arg4
push   0x3 ; arg3
push   0x2 ; arg2
push   0x1 ; arg1
call   _stdcall_fct@16
mov    DWORD PTR [ebp-0x4],eax

As for the cdecl calling style, arguments are pushed from right to left, but in stdcall mode, the caller doesn’t have to clean the arguments from the stack after calling the function. A stdcallfunction removes arguments from the stack before returning. This is done by using the ret n instruction most of the time.
Like for cdecl, result is in EAX.

fastcall convention

The fastcall convention is not standardized, but we will watch the way GCC and MSVC handle it. A function can be declared as afastcall function in C with this syntax (GCC):

__attribute__((fastcall)) int function(int arg1, int arg2, ...);

GCC will produce the following code when calling a stdcall function with 4 arguments :

push   0x4 ; arg4
push   0x3 ; arg3
mov    edx,0x2 ; arg2
mov    ecx,0x1 ; arg1
call   @fastcall_fct@16
mov    DWORD PTR [ebp-0x4],eax

As you can see, not all the arguments are pushed into the stack. The first two arguments are passed via the ECX, for the first argument, and EDX, for the second argument. The remaining arguments are pushed into the stack from right to left. The called function has to pop the arguments from the stack before returning, like for stdcall.
The result is, as usual, in EAX :)


Posted by code cat