vi에서 설정이 부족해서(?) backspace 키나 화살표키 등이 안먹힌다.


그래서 ~/.exrc 파일에 몇가지 설정을 해주면 잘 동작한다.

(걍 vim 설치해서 쓰면되긴 한다.)



그렇다면 저 파일은 뭘까해서 찾아봤당.


vi 사용시, user의 home 디렉터리에서 이 파일을 찾아서 설정을 반영한다.

indentation, tab space 설정 같은것 들이다.

대게 이런 설정은 파일이 열려있을 때 까지만 유효하기 때문에 .exrc라는 파일에 설정을 Group화 할 수 있다.



vim 설정파일인 .vimrc 같은 것 이다.




암튼 저 상황에 대한 해결책은


$ cd ~

$ vi .exrc


set autoindent

set number

set bs=2

set nocp



$ source .exrc         // 적용



'System > Linux OS ' 카테고리의 다른 글

리눅스 환경변수와 UID, PID, 시스템자원의 제한  (0) 2015.12.24
lsof  (0) 2015.12.24
strace, ltrace  (0) 2015.12.24
gcc / gdb  (0) 2015.12.24
man  (0) 2015.12.24

냉장고에 새우가 있길래 ㅋㅋㅋㅋ

뒤포리? 라는걸 육수낼 때 같이 넣어봤는데, 

걍 멸치랑 다시마로만 육수낸게 더 깔끔하다.

이건.. 뭔가.. 시원한 맛보다는 풍부한 맛이갈까..?







'취미 ㅋㅋ' 카테고리의 다른 글

LA갈비  (0) 2016.03.06
레고 시청 / 파리레스토랑 / 펠리스시네마  (0) 2016.03.04
레고 소방대  (0) 2016.03.04
레고 백화점  (0) 2016.03.04
브라우니  (0) 2016.02.13

사진찍기가 왜케 귀찮은지 ㅋㅋ 

생각난김에 !!



역시 한식엔 마늘이 팍팍 들어가야 제맛..




'취미 ㅋㅋ' 카테고리의 다른 글

순두부탕  (0) 2016.03.06
레고 시청 / 파리레스토랑 / 펠리스시네마  (0) 2016.03.04
레고 소방대  (0) 2016.03.04
레고 백화점  (0) 2016.03.04
브라우니  (0) 2016.02.13



이전

__turn_mmu_on, __turn_mmu_on_end영역만 page table에 매핑









__create_page_table  계속...


커널 코드 시작부터 .bss 섹션의 끝까지 메모리를 매핑한다.

page table의 시작위치는 0x4000 (r4)




* x >> (20-2)

 

1) 

x >> 18

x / 2^18

x / (2^20 x 2^2)


2)

x >> 20       ; x/1M

x << 2         ; x*4



그 후, BSS의 마지막 부분을 매핑한다.

_end(.bss section의 끝) 0x8092378C -1 상수값을 r6에 넣는다.

(참고. https://github.com/iamroot12D/linux/issues/31)


cf)

arm명령어 체계에서는 상수를 맨 오른쪽 비트 1개만 사용하여 표현하기때문에

0~256까지만 표현할 수 있기때문에, 상수자체가 256이 넘는 것은 계산할 수가 없다.

즉, mov r0, 270 은 안된다.


하지만, 

mov r0, 0xlf00000000

=> 상수 0xlf에, shift bit에 24가 들어가서 계산이 된다.


즉, 소스에서 상수를 로드할 때, mov가 아닌 ldr을 사용하는 이유이다.



여기까지 우리가 하는 일을 잠시 다시 생각해보자.








메모리 매핑 현재 과정




다시 소스 !!


r6 : .bss의 끝(.end) 0x8092378b

r7 : mmu_flags 값

r8 : 물리메모리의 시작, 0x0 (커널의 베이스 어드레스)


(cf. bss영역이 9.X M정도여서, 약 10M 라고 가정하에... 그림그림.)

=> 찾아보니, 정확히 한 9.2M정도 이넹~~ 





=> 즉, 

r6 = 0x809   => 0x2024

즉, 0x6000~0x6024까지 커널의 .bss섹션까지의 영역과 매핑한다.


....









.bss위에 DTB가 있었는데, 이것도 옮긴다.

r3 = 6028    ; DTB의 영역을 매핑할 주소를 구함

가상메모리에서 6028와 매핑되어있는 물리주소 


2번 수행해서 2M영역을 페이지 테이블에 맵핑하는 이유는, 

DTB의 최대 사이즈가 1M 일 수 있다. 우리의 페이지 엔트리는 1M 단위로 하는데, .bss까지의 .end가 9.2정도 이므로, 10M 영역을 넘을 수 있기때문에,

영역이 겹쳐버릴 수 있다. 그래서 2번 수행해서 총 2MB을 추가로 확보하는 것이다.


* addruart  :  UART 장치의 선두 주소를 얻어옴. 레지스터에 시리얼 포트 주소 값을 설정)

kconfig에서 값을 읽어와서 레지스터들을 로드

addruart r7, r3, r0      ; r7 물리주소 0x20201000, r3 가상주소 0xf0201000
r7 = io의 mmuflag값, 0xc02

0xc02 => c는 앞에비트니까 생각하지말고, 02는 0010으로

c                    b

 ...

 ...

 0

 0

 1

 0



r3 = 0xf0201000를 20번 right 시프트하면 5개자리가 떨어져나가서 0xf02(물리주소)이고, 

r3 = 이걸 두번 다시 left shift하면 0xf02 * 4

r3 = (0xf02 * 4) + 0x4000 = 0x202

r7 = 0x202 = 0xc02

r0 = 0x7c08

r3 = 0x2020000+0x00000c02

r3 = 20200c02

여기에 xn비트 적용하면, r3 = 0x20200c12  


* xn비트(execute never)가 서있으면, https://en.wikipedia.org/wiki/NX_bit


이걸 페이지 테이블에 매핑하면 가상주소의 인덱스가 7c08인 값이 20200c12



참고.

http://kth3321.blogspot.kr/2013/04/arm-cortex-1.html




디버깅에 필요한 잡업들을 위해 매핑까지 수정하면,



ret lr 

(리턴  lr!! creatfe page끝 )





<결론>


* 커널이 사용할 2GB : PAGE_OFFSET 값으로


* 가상주소를 물리주소로 변환하는 방법

은 right shift 20, left shift 2 



이전시간에 turn_mmu_on 을 가상 메모리 공간에 0M부분에도 매핑하는데, 오늘은 커널부분을 커널영역부분에 맵핑했다

결국 turn_mmu_on이 매핑되는 부분은 2군데가 되는데

이는 turn_mmu_on을 하기 전까지 우리는 커널영역의 주소공간을 사용한다.  

즉, 가상메모리 주소공간이 0x80000000 공간을 사용하지 않고 0x0~~ 주소체계를 사용하고 있기때문에 바로 주소가 변환하는 매커니즘을 거치면 오류가 발생하기 때문에, 

이를 방지하기 위해 따로 매핑을 해놓고 사용한다.









* head.S에서 지금까지한게 SMP랑 __create_page_table









[initfn 매크로 부분]


r10 :  proc.info 구조체,  (라즈베리파이의 CPU의 proc.info)


(실행주소가 0x8000베이스로 실행되는 중)


--v7proc_info는 파일에 들어있는 값이고 0x80008200이런식으로 되어있었다. (지난번에 했음)

v7proc_info 들어가면, __lookup_processor_type레이블이 있고, __lookup_processor_type_data를 타고 0x8080이 들어갔다고 치고,  (실행주소가  0x8000베이스로 돌아가는 중, 런타임시)

__lookup_processor_type돌아와서 adr명령어를 통해서 r3 = 0x8080 로 들어간다. 

*adr명령어는 PC의 기준으로 현재 실행되고있는 메모리의 값을 읽어오는 거라서(런타임시), 0x8000베이스고,


(덤프확인 주소들이 https://github.com/iamroot12D/linux/issues/31)

 r3

 r4 

 r5 

 r6 

 0x8080

 "."은 현재 데이터이므로

0x80008080

(컴파일시점에서 소스에 박힘)

 

 

 (** arm 명령어체계)


2: .long 0x80008080 => r4

    .long 0x80000000 




initfn    --v7-setup, --v7proc_info    => 이렇게 빼주는게, 컴파일시에 읽어온 0x80000000 베이스의 주소를

 현재 런타임에 사용되는 베이스인 0x8000 형식으로 만들어주기위해 빼주는 과정임.

(initfn가 --v7-setup - --v7proc_info 하는 매크로임)



예를들어

initfn 80008300, 80008400




=> r12에는 -100이 들어감

r10 = 8400

-------------

이 둘을 add해서 r12에 저장, 즉 8400 + (-100) = 8300

결국 --v7_setup(80008300)인 컴파일시점의 주소를 현재 실행중인 베이스인 0x8000으로 바꾸는 역할을 하는 코드임.


결국 0x8000000을 0x8000베이스로 바꿔주기위해서 앞부분을 빼주는 역할을 함

=> 결국 이것도, 메모리에 있는 --v7_setup매크로를 호출하기 위해서 이렇게 한거.


자, 이제 v7_setup로 쩜프~!!







(아 왜 이렇게 짠거야...?에 대한 토론)


CISC와 다르게 RISC에서는 무조건 4바이트 명령어로 16비트 명령어 체계에서 2byte만 상수를 표현할수 있다. (0-256) 

그래서 한줄로 표현할수있는 것도, 복잡하게 여러줄로 나눠서 표현해야하기도 함.

위에서 봤던, ldr, mov명령이라던가...


CISC도 파이프라이닝을 위해서 SISC 처럼 명령어를 마이크로 명령어라는 단위로 잘라서 사용하기도 한다. 

이런 테크닉들이 많이 있다.



CISC는 명령어 길이가 가변적이므로, 설계도 복잡해지고 CPU성능에도 많은 가변적인 문제가 있다.








모듈러

시청 10224 

파리레스토랑 10243

펠리스시네마 10232




'취미 ㅋㅋ' 카테고리의 다른 글

순두부탕  (0) 2016.03.06
LA갈비  (0) 2016.03.06
레고 소방대  (0) 2016.03.04
레고 백화점  (0) 2016.03.04
브라우니  (0) 2016.02.13

모듈러 소방대 10197




'취미 ㅋㅋ' 카테고리의 다른 글

LA갈비  (0) 2016.03.06
레고 시청 / 파리레스토랑 / 펠리스시네마  (0) 2016.03.04
레고 백화점  (0) 2016.03.04
브라우니  (0) 2016.02.13
뿌팟퐁커리  (0) 2016.02.13

모듈러 백화점 10211



'취미 ㅋㅋ' 카테고리의 다른 글

레고 시청 / 파리레스토랑 / 펠리스시네마  (0) 2016.03.04
레고 소방대  (0) 2016.03.04
브라우니  (0) 2016.02.13
뿌팟퐁커리  (0) 2016.02.13
낙지볶음/덮밥  (0) 2016.02.13

head.S




; 컴파일 시점에 이루어짐


r3 : r2번 레이블의 물리주소 0x8080

r4 : 2번 레이블의 가상주소 0x80008080

r8 : 커널 메모리 시작 offset. 0x80000000

r8 = r8 + r4 (0x8000000 + 0x8000000 = 0x0  -> overflow 발생으로 더한값이 0이 된다.)


#ifndef CONFIG_XIP_KERNEL

adr    r3, 2f

ldmia r3, {r4, r8}

sub    r4, r3, r4         ; r3-r4 = 0x8080 - 0x80008080   이상태에서 -플래그가 세워지지는 않음(명령어에s가 없으니까ㅋㅋ) 값은 0x8000000

add    r8, r8, r4        ; r8을 delta값처럼 쓴다? create page table에서 사용.... (r8의 용도는 무엇인가?!)

#else

ldr    r8, =PLAT_PHYS_OFFSET    ;  PLAT_PHYS_OFFSET이 0으로 설정되어있음

#endif



=> MMU를 설정하기 전이라 가상주소를 사용할 수 없기때문에, 이런 식으로 주소설정을 해준다. (이를 위해 base address를 0으로..?)

https://github.com/raspberrypi/linux/commit/72a20e22f49e2dad3180c23980a9df1c63faab0a




* __create_page_tables: 페이지테이블을 0으로 초기화하는 과정


- page_table 인자(rd, phys)로 넘어온걸 계산하는 매크로 

- r4에 페이지테이블의 시작 주소를 구한 후 루틴에 들어간다. 

(어떤 루틴인가~~~시작!)





* ###_LPAE ? 우리는 세팅이 안되어있어서 스킵됨


* 인라인 어셈블러

1. https://wiki.kldp.org/KoreanDoc/html/EmbeddedKernel-KLDP/app3.basic.html 

* clobber가 메모리 배리어

* =r 포인터

* I는 integer라서 커널소스에서보면, i가 쓰임


2. http://codecat.tistory.com/entry/%EC%9D%B8%EB%9D%BC%EC%9D%B8-%EC%96%B4%EC%85%88%EB%B8%94%EB%A6%AC

3. http://stackoverflow.com/questions/25294649/how-does-this-inline-assembly-define-a-variable


스크립트로 C언어의 DEFINE을 쫙구현할때 main()에서 인라인어셈블러문법을 사용해서 쫘르륵 설정한다. 

     참고로 '->' 는 인라인어셈블러문법에서 자동으로 값들을 설정하기위해서 스크립트를 이용하는데 이때 상수로 쓰기위한 문법?

'sed script' => stream editor의 약자로 \n를 사용해서 시작한다.


ex. 리눅스 명령어로 사용할 때, aa.c라는 파일을 cc.c로 바꿀 때,

$ ls | sed 's/aa/cc/g'

     

참고2.  #define문법(C에서는 컴파일타임)을 안쓰고 offsetof을 사용해서 구현한 이유는 뭘까?

define할 값들을 스크립트를 통해서 동적으로 적용하기 위해서는 런타임 시점에 값을 변경해야 할 필요가 있음. 


참고1, 참고2 => 일종의 코드생성을 위해 sed를 일반적으로 사용하는데 이를 이용해서 헤더파일을 만들어서 define들을 만들어서 사용할라고~~




* ldr    r7, [r10, #PROCINFO_MM_MMUFLAGS] 0 mm_mmuflags


r7 = __lookup_process_type으로 proc_info를 가지고와서 r10에 저장해 놨었음


__lookup_process_type를 쭉 따라들어가면 PROC_INFO라고 define시키는 구문이 있음 (vmlinux의 섹션헤더 부분에 데이터들이 박히게된다.)

-> __lookup_process_type_data   -> ###_begin, ###_end 중간에 포인터들로 박힌다. 

=> /linux/arch/arm/mm/proc-v7.S를 확인해보면 소스 확인 가능함 ('proc.info.init'으로 검색)

=> .macro __v7_proc

=> ALT_SMP  => PMD_TYPE_SECT, ... 비트셋팅!

이렇게하면 비트들이 설정이 된다.

여기까지하면 플래그 값이  0x11c0e


...... 여기서 유니프로세스랑 멀티프로세스일때 어케 되는지(ALT_UP)

- 유니 : 0xc02

- 멀티 : 0xc0e




* adr r0, __turn_mmu_on_loc     ; mmu turn on 주소를 r0에 넣기



r0 = __turn_mmu_on_loc의 물리주소 0x8134

r3 = __turn_mmu_on_loc의 가상주소 0x80009134

r5 = __turn_mmu_on의 주소 0x80008240

r6 = __turn_mmu_on_end의 주소 0x80008260


... github  소스랑 주석 참고 





r4에 페이지테이블의 시작 주소를 구했었음. 



00100000

(base가 됨)






---------------------------


* XIP : 커널을 압축하지 않고 ROM FLASH에서 바로 실행되는 커널

* ARMSim - The ARM Simulator Dept. of computer science

* arm-bcm###

arm-linux-gnueabihf-objdump (cross compile)

(http://hybridego.net/entry/armlinuxgnueabihfgcc-%EC%99%80-armlinuxgnueabigcc-%EC%B0%A8%EC%9D%B4)





--------------------------

page offset

physical offset

text offset

Entry point address

Coherent, coherence 캐시 일관성 관련




##### Unit 25. Can, could, and (be) able to 

~ 할수있다.





#1. Can



a. We use "can" to say that something is possible or allowed, or that somebody has the ability to do something


* We use can + base form (can do / can see, etc.):


+ We can see the ocean from our hotel window.

+ Can you speak any foreign languages?

+ I can come and help you tomorrow if you want.

+ The word "dream" can be a noun or a verb.


* The negative is can't(= cannot)


+ I'm afraid I can't come to your party on Friday.




#2. is able to



a. You can say that somebody is able to do something, but can is more common:


+ We are able to see the ocean from our hotel window.



b. Can has only two forms: can (present) and could (past)

So sometimes it is necessary to use (be) able to


 I can't sleep.  

 I haven't been able to sleep recently. 

 Tom can come tomorrow.

 Tom might be able to come tomorrow. 

 Maria can speak French, Spanish, and English.

 Applicants for the job must be able to speak two foreign languages.





#3. Could


a.  the past of can (use it especially with : see / hear / smell taste feel remember understand)


+ We had a nice room in the hotel. We could see the ocean.

+ She spoke in a very soft voice, so I couldn't understand what she said.


b. use it to say that somebody had the general ability or permission to do something:


+ My grandfather could speak five languages.

+ We were totally free. We could do what we wanted.




#4. Could & was able to


positive

 negative

could

 use it for general ability

 couldn't

was able to

 use it somebody did something in a specific situation

 managed to



compare:


+ Jack was an excellent tennis player when he was younger. He could beat anybody. 

+ Jack and Ted played tennis yesterday. Ted played very well, but Jack managed to / was able to beat him.






# Exercises


+ We had a really good vacation. It couldn't have been better.

+ I couldn't have wear that hat. I'd look sill, and people would laugh at me.

+ We managed to find the restaurant you recommended, but we couldn't have find it without the map that you drew for us.

+ The staff at the hotel was really nice when we stayed there last summer, They couldn't have been more helpful.

+ That's nice of you, but I couldn't have come anyway. I was away all last week.





##### Unit 24. When I do / When I've done, When and if

~ 할 때,





#1. When I do (When)


"I'll call you when I get home from work" is a sentence with two parts:


- the main part : I'll call you    and

- the when part : when I get home from work


a. The time in the sentence is future (tomorrow), but we use a present tense (I get) in the when part of the sentence.

We do not use will in the when part of the sentence.


+ We'll go out when it stops raining.

+ When you are in Los Angeles again, give us a call.

+ (said to a child) What do you want to be when you grow up? 



b. The same thing happens after while / before / after / as soon as / until or till :


+ I'm going to read a lot of books while I'm on vacation.

+ I'll probably go back home on Sunday. Before I go, I'd like to visit a museum.

+ Wait here until(or till) I come back.




#2. When I've done (Present Perfect) 



a. You can also use the present perfect(have done) after when / after / until / as soon as:


+ Can I borrow that book when you've finished it?     너 그거 끝낸거면 나 책 좀 빌릴 수 있을까?

+ Don't say anything while Ben is here. Wait until he has gone.    벤이 여기있는 동안 아무것도 말하지마. 그가 가기까지 기다려.



b. If you use the present perfect, one thing must be complete before the other (so the two things do not happen together):


+ When I've called Kate, we can have dinner.

(First I'll call Kate, and after that we can have dinner.)


Do not use the present perfect if the two things happen together:

+ When I call Kate, I'll ask her about the party. (not When I've called)





#3. When and if 



a. If, we normally use the simple present (if I do / if I see, etc.) for the future:


+ It's raining hard. We'll get wet if we go out. (not if we will go)

+ I'll be angry if it happens again.

+ Hurry up! If we don't hurry, we'll be late.



b. Compare when and if:


* We use when for things that are sure to happen:

+ I'm going shopping later. (for sure) When I go hopping, I'll get some cheese.


* We use if for things that will possibly happen:

+ I might go shopping later. (it's possible) If I go shopping, I'll get some cheese.


+ If it is raining tonight, I won't go out. (not When it is raining)

+ Don't worry if I'm late tonight. (not when I'm late)

+ If they don't come soon, I'm not going to wait. (not When they don't come)





# Exercises


+ I'm going out now. If anybody calls while I am out, can you take a message?


+ I'll fine a place to leave to live. Then I'll give you my address.

=> I'll give you my address when I find a place to live.


+ I'll go shopping. Then I'll come straight home.

=> I'll come straight home after I do the shopping or I've done the shopping.


+ It's going to get dark. Let's go home before that.

=> Let's go home before It gets dark.


+ You want to sell your car. Jim is interested in buying it, but he hasn't  decided yet. 

You ask: Can you let me know as soon as you decide or you've decided?


+ The traffic is very bad in your town, but they are going to build a new road. 

You say: I think things will be better when they build the new road or have built the new road.


+ We can eat at home, or if you prefer, we can go to a restaurant.





+ Recent posts