VGA 관련

Programming/OS Development 2009. 6. 19. 22:59
VGA를 사용을 위한 각 비디오 포트 설명 문서

VESA 2.0 Specification

VESA BIOS Extendsion 3.0 문서
256-Color VGA Programming in C 
 

'Programming > OS Development' 카테고리의 다른 글

NASM - 3  (0) 2009.06.29
NASM - 2  (0) 2009.06.29
하드 디스크 드라이버 ( Hard Disk Driver )  (0) 2009.05.29
OS 제작의 원리 그리고 Codes - Ch 6. Memory Management  (1) 2009.05.19
메모리 주소별 용량.  (0) 2009.05.15

설정

트랙백

댓글

[MFC] Bitmap Object

In GDI, Funcs are not supported about JPG, GIF. However, Funcs are supported about JPG, GIF in GDI++. There are tow kinds of Bitmap, DDB( Device Dependent Bitmap ) and DIB( Device Independent Bitmap ). It is able to paint as ever, regardless of OS( Operating System ) because DIB contains much Info about Bitmap. Just use DIB, when u create Bitmap file.

'Programming > Windows Programming' 카테고리의 다른 글

라디오 버튼 그룹지정 하기  (0) 2009.08.22
IP HELP API 설정하기  (0) 2009.08.22
[MFC] 더블 버퍼링  (0) 2009.06.22
[MFC] GDI( Graphics Device Interface )  (0) 2009.06.07
[MFC] FileOpen  (0) 2009.06.04

설정

트랙백

댓글

[MFC] GDI( Graphics Device Interface )

DC( Device Context )
GDI is supported by Windows OS to process the problem from compatibility with new Graphic Cards. If u use GDI, u don't need to care about a kind of devices.
Create DC to choose a device which u r going to use. After creating DC, GDI returns the handler of the DC. Then, u are able to use the device via the handler. U must release DC, after using the DC. Or else, Memory Leak occurs.

MFC DC( Device Context )
The below illustration is MFC Class Table.

CObject--
              |-- CDC
                 |-- CClientDC
                 |-- CMetaFileDC
                 |-- CPaintDC
                 |-- CWindowDC

1) CDC Class
CDC Class is the base class of other DC classes. In MFC Application, CWnd::GetDC Func returns CDC class pointer. After painting via the CDC pointer, u must release the DC using CWnd::ReleaseDC Func.

2) CWindowDC Class
It's for the entire region of Window. It contains Caption Bar, Menu Bar, Tool Bar, State Bar and so on... ,and besides Client region, that is, the entire region of Window.
GetWindowDC Func returns DC and ReleaseDC Func releases DC.

3) CClientDC Class
It's for client region in a Window. ClientDC Func returns DC and ReleaseDC FUnc releases DC or U could use delete with the pointer for DC.
ex ) CClientDC* pClientDC = new CClientDC( this );
       delete pClientDC;

4) CPaintDC Class
It's used in OnPaint Member Func which is WM_PAINT Message handler Func, when a window is being redrawed by WM_PAINT message. CPaintDC dc(this)  Func gets a pointer of Paint DC.

5) CMetaFileDC Class
It manages DC which are related with MetaFile( WMF, EMF ). MetaFile is a file of a group of GDI commands.

'Programming > Windows Programming' 카테고리의 다른 글

라디오 버튼 그룹지정 하기  (0) 2009.08.22
IP HELP API 설정하기  (0) 2009.08.22
[MFC] 더블 버퍼링  (0) 2009.06.22
[MFC] Bitmap Object  (0) 2009.06.07
[MFC] FileOpen  (0) 2009.06.04

설정

트랙백

댓글

[MFC] FileOpen

1. 이 두 파일을 프로젝트에 추가한다. "MyFileDialog.cpp", "MyFileDialog.h"

2. 파일 열기 때 사용할 다이얼로그를 하나 만들고 옵션을 수정한다.
    -> Clip Siblings : True, Style : Child, Control : True, System Menu : False
   그리고, 창의 길이를 옆으로 늘인다( 실제 파일 오픈 할 때 열리는 다이얼로그 보다 크게... 그렇지 않으면 이 다이얼로그의 테두리가 파일 열기 다이얼로그에 보이게 된다).

3. 리소스에 메뉴를 추가하고, 이벤트 핸들러를 추가한다.
    -> Message Type : COMMAND,  Function Handler Name : OnFileOpen, Class List : 이벤트 핸들러를 추가할 다이얼로그.( A Dialog )

4. A Dialog 의 옵션에 있는 Menu 에 이 새로 만든 Menu를 등록시킨다.

5. 메뉴 이벤트 핸들러에 아래의 소스를 붙여 넣고 수정하여 사용한다.

멀티바이트 용

char szFilter[] = "Text File|*.txt|All Files (*.*)|*.*||";
 CMyFileDialog Dlg( TRUE, "txt", NULL, NULL, szFilter );
 Dlg.m_ofn.lpstrTitle = "KnapsackProblem : Open File";
 if( Dlg.DoModal() == IDOK )
 {
 
 }

유니코드 용
CString szFilter = _T( "HTML 파일|*.htm|All Files (*.*)|*.*||" );
 CMyFileDialog Dlg( TRUE, (LPCTSTR)("txt"), NULL, NULL, szFilter );
 Dlg.m_ofn.lpstrTitle = _T("파일 열기");
 if( Dlg.DoModal() == IDOK )
 {

'Programming > Windows Programming' 카테고리의 다른 글

라디오 버튼 그룹지정 하기  (0) 2009.08.22
IP HELP API 설정하기  (0) 2009.08.22
[MFC] 더블 버퍼링  (0) 2009.06.22
[MFC] Bitmap Object  (0) 2009.06.07
[MFC] GDI( Graphics Device Interface )  (0) 2009.06.07

설정

트랙백

댓글

Static Member

Programming/C++ Language 2009. 5. 31. 22:59
Static Data Member has Class Scope. Static Member could be defined as Public, Protected, Private. It must to be defined once in File Scope, such as "CGameUnit* CGameUnit::aUserUnit[2] = {NULL, NULL};". Because If you don't, Compiler makes "error LNK2001", "fatal error LNK1120: 1개의 확인할 수 없는 외부 참조입니다.", "외부 기호를 확인할 수 없습니다.".
The case of Public static, U can use this with Binary Scope resolution operator( :: ) and a name of Class, such as "Martian::martiancount".
The case of Private or Protected static, Public static Member function must be exist. This Public Static Function must be called with a name of Class and "::".

When it's inherited, If it's Public or Protected, U could use it w/out Public Static Function in inherited Class. Buf if it's Private, U must use it via Public Static Function in inherited Class.


'Programming > C++ Language' 카테고리의 다른 글

namespace  (0) 2010.03.19
연산자 오버로딩  (0) 2009.09.30
순수 가상 함수  (0) 2009.09.26
가상 함수의 활용  (0) 2009.09.25
가상 함수에 대한 이해  (0) 2009.09.25

설정

트랙백

댓글

하드 디스크 드라이버 ( Hard Disk Driver )

Programming/OS Development 2009. 5. 29. 23:38
Hard Disk Driver is the program to control Hard Disk.



As the upper picture, Hard Disk is consist of "Platter". Platters' circle is called "Track". The invariable part of Track is called Sector. This is the smallest unit of Writting in Disk which is usually 512 Bytes.
There are two modes to access Hard Disk. The first one is called "CSH Mode", the another one is called "LBA Mode( Logical Block Address )".
The former one has the limitation of capacity( 528 MB ). Controlling Hard Disk using Sector 6-bit, Head 4-bit, Track 10-bit and one sector is 512-byte. Therefore, The max capacity which is capable of being controlled is 528MB( = 2^20 * 512-byte ). But the latter one is not. It sees Hard Disk as a group of linear sector. it could be controlled as long as knowing the total number of sector of Hard Disk.

'Programming > OS Development' 카테고리의 다른 글

NASM - 2  (0) 2009.06.29
VGA 관련  (0) 2009.06.19
OS 제작의 원리 그리고 Codes - Ch 6. Memory Management  (1) 2009.05.19
메모리 주소별 용량.  (0) 2009.05.15
어셈블러에서 16진수 입력  (0) 2009.05.15

설정

트랙백

댓글

OS 제작의 원리 그리고 Codes - Ch 6. Memory Management

Programming/OS Development 2009. 5. 19. 02:29

To calculate the size of physical memory

We could calculate in a simple way to check data. Writting data from the certain address then read it. Comparing that two data. If it's the same, there is memory. If not, there is no memory.
 

 // 실메모리의 크기를 구한다.
int nGetPhysMemSize()
{
 int  nI, nSize;
 UCHAR *pX, byTe;;

 // 실메모리의 크기를 구한다.
    
 // 메모리는 512메가부터 2기가 바이트까지 뒤진다.
 for( nSize = nI = 512; nI < 2048; nI++ )
 {
  pX = (UCHAR*)( nI * (ULONG)0x100000 );  //  nl * 1MB
  

  byTe = pX[0];         // The start address of the memory.
  byTe++;                 // Increasing the value of the start address.
  pX[0] = byTe;        // Writting the value on the start address.
  if( byTe != pX[0] )  // Comparing between the increased data and the value of the start address.
   break;                  // If it's not the same, there is no memory on that address.
  else
   nSize++;              // If it's the same, there is memory. Keep calculating.
        
        pX[0] -= 1;     // Restoring to the previous value
 }

 return( nSize * 0x100000 );  // 바이트 단위로 리턴한다.
}



Physical Memory Management Table

Assigning 1byte to save the status of physical memory. It's like Reference Counter.
When it's zero, it's not used and is available. When it's five, five processors are using it by mapping.

Each page has 1024 entries, which is 4 byte. It means 4 KB allocate to each page.
There are 256 pages In 1 MB Memory. That's why needing 256 byte per 1MB.

To save the counter for 1024MB Memory, 1024 * 256 bytes ( 256 KB ) are required.
Putting P.M.M.T right after kernel image. But, it is no matter where you put P.M.M.T.

Caution ) There is the space for ROM BIOS on 0xF0000. You must not write any data on that.

// allocate one physical page
 DWORD dwAllocPhysPage()
{
 int  nI;
 UCHAR *pTbl;

 pTbl = bell.pPhysRefTbl; // Physical Memory Management Table

 // search after 64K
 for( nI = 16; nI < bell.nPhysRefSize; nI++ )
 {
  // if the address is video memory then next search is started at 1.5M( = 0x180000 ) area
  if( nI == ( (int)0xA0000 / 4096 ) ) // Skipping the space of ROM BIOS.
   nI = ( (int)0x180000 / 4096 );

  if( pTbl[nI] == 0 )
  {
   pTbl[nI]++;  // increase counter
   return( (DWORD)( (DWORD)nI * (DWORD)4096 ) );
  }
 }
 return( 0 ); // allocation failed
}


 int nFreePage( DWORD dwPhysAddr )
{
 DWORD dwI;
 UCHAR *pTbl;

 dwI = (DWORD)( dwPhysAddr / (DWORD)4096 );

 pTbl = bell.pPhysRefTbl;
 if( pTbl[dwI] == 0 )
  return( -1 );   // 할당되지 않은 메모리이다.

 pTbl[dwI]--;  // Decreasing the counter value with 1

 return( 1 );
}


'Programming > OS Development' 카테고리의 다른 글

VGA 관련  (0) 2009.06.19
하드 디스크 드라이버 ( Hard Disk Driver )  (0) 2009.05.29
메모리 주소별 용량.  (0) 2009.05.15
어셈블러에서 16진수 입력  (0) 2009.05.15
naked 함수  (0) 2009.05.11

설정

트랙백

댓글

메모리 주소별 용량.

Programming/OS Development 2009. 5. 15. 03:30
0x100 -> 16 * 16 = 256 byte
0x200 -> 16 * 16 * 2 = 512 byte
0x1000 -> 16 * 16 * 16 = 4 KB
0x10000 -> 64 KB
0x100000 -> 1 MB

'Programming > OS Development' 카테고리의 다른 글

하드 디스크 드라이버 ( Hard Disk Driver )  (0) 2009.05.29
OS 제작의 원리 그리고 Codes - Ch 6. Memory Management  (1) 2009.05.19
어셈블러에서 16진수 입력  (0) 2009.05.15
naked 함수  (0) 2009.05.11
Stack Frame  (0) 2009.05.11

설정

트랙백

댓글

어셈블러에서 16진수 입력

Programming/OS Development 2009. 5. 15. 02:01
0Eh or 0EH, 0201H, 0AA55H.

여기서 h 는 16진수를 표시하기 위한 것으로 소/대 문자 어떤 것을 사용해도 됩니다.
그리고 앞에 붙는 0은 그 다음 나오는 것이 문자( A, B,C, D, E)일 경우에는 사용해야 하지만
숫자일 경우에는 0을 항상 붙일 필요가 없습니다.

'Programming > OS Development' 카테고리의 다른 글

OS 제작의 원리 그리고 Codes - Ch 6. Memory Management  (1) 2009.05.19
메모리 주소별 용량.  (0) 2009.05.15
naked 함수  (0) 2009.05.11
Stack Frame  (0) 2009.05.11
NASM - 1  (0) 2009.03.11

설정

트랙백

댓글

naked 함수

Programming/OS Development 2009. 5. 11. 03:06
__naked 호출 규약은 컴파일러가 접두, 접미를 작성하지 않는 호출 규약이다.
스택 프레임의 상태 보존을 위해 컴파일러가 어떤 코드도 작성하지 않으므로 접두, 접미는 사용자가 직접 작성해야 한다. C에서는 inline 어셈블리를 사용해야 한다.
함수 정의부에 __declspec(naked) 를 적어주면 naked 호출 규약을 사용 할 수 있다.

'Programming > OS Development' 카테고리의 다른 글

메모리 주소별 용량.  (0) 2009.05.15
어셈블러에서 16진수 입력  (0) 2009.05.15
Stack Frame  (0) 2009.05.11
NASM - 1  (0) 2009.03.11
Segmant and Offset  (0) 2009.03.08

설정

트랙백

댓글