sync with trunk #913

git-svn-id: svn://kolibrios.org@914 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2008-11-07 04:10:42 +00:00
parent a26689b104
commit c01a33cfa5
24 changed files with 4392 additions and 1187 deletions

View File

@ -277,18 +277,22 @@ int sys_exec(char *path, char *cmdline, u32_t flags)
( raw[1] == 0x30305445) ) )
{
DBG("leagacy Kolibri application\n");
DBG("leagacy Kolibri application");
int tmp = mnt_exec(raw, raw_size, path, cmdline, flags);
DBG(" pid %x\n",tmp);
return tmp;
}
if( ! validate_pe(raw, raw_size) )
if( ! validate_pe(raw, raw_size, true) )
{
DBG("invalid executable file %s\n", path);
mem_free(raw);
return -31;
}
dos = (PIMAGE_DOS_HEADER)raw;
nt = MakePtr( PIMAGE_NT_HEADERS32, dos, dos->e_lfanew);
pathsize = strlen(path)+1;
if( cmdline )
@ -359,8 +363,7 @@ int sys_exec(char *path, char *cmdline, u32_t flags)
DBG("create stack at %x\n\tpath %x\n\tcmdline %x\n",
ex_stack, ex_stack->path, ex_stack->cmdline);
pe_app_param(path, raw, ex_pg_dir, ex_stack);
return 0;
return pe_app_param(path, raw, ex_pg_dir, ex_stack);
};
#define master_tab (page_tabs+ (page_tabs>>10))
@ -394,6 +397,10 @@ void sys_app_entry(addr_t raw, thr_stack_t *thr_stack, exec_stack_t *ex_stack)
size_t img_size;
count_t img_pages;
size_t stack_size;
addr_t img_stack;
addr_t *pte;
count_t i;
u32_t tmp;
@ -408,18 +415,26 @@ void sys_app_entry(addr_t raw, thr_stack_t *thr_stack, exec_stack_t *ex_stack)
list_initialize(&current_slot->dll_list);
pte = (addr_t*)page_tabs;
img_pages = img_size >> 12;
for(i = 0; i < img_pages; i++)
{
addr_t page = core_alloc(0);
((u32_t*)page_tabs)[i] = page | 7; /* FIXME */
}
stack_size = (nt->OptionalHeader.SizeOfStackReserve + 4095) & ~4095;
img_stack = 0x7FFFF000 - stack_size;
stack_size>>= 12;
while (img_pages--)
*pte++ = 2;
pte = &((addr_t*)page_tabs)[img_stack>>12];
while(stack_size--)
*pte++ = 0x02;
addr_t stack_page = ((addr_t)ex_stack-OS_BASE) & ~4095;
((u32_t*)page_tabs)[0x7FFFF000>>12] = stack_page | 7;
create_image(0, raw);
*pte = stack_page | 7;
create_image(0, raw, false);
init_user_heap();
@ -430,8 +445,9 @@ void sys_app_entry(addr_t raw, thr_stack_t *thr_stack, exec_stack_t *ex_stack)
"int $0x40"::"a"(-1));
};
// __asm__ __volatile__ (
// "xchgw %bx, %bx");
// __asm__ __volatile__ (
// "xchgw %bx, %bx");
addr_t entry = nt->OptionalHeader.AddressOfEntryPoint +
nt->OptionalHeader.ImageBase;
@ -481,7 +497,7 @@ dll_t* __fastcall load_dll(const char *path)
return NULL;
};
if( ! validate_pe(raw, raw_size) )
if( ! validate_pe(raw, raw_size, false) )
{
DBG("invalid pe file %s\n", path);
mem_free(raw);
@ -508,7 +524,7 @@ dll_t* __fastcall load_dll(const char *path)
return NULL;
};
create_image(img_base, (addr_t)raw);
create_image(img_base, (addr_t)raw, false);
mem_free(raw);
@ -609,22 +625,24 @@ bool link_pe(addr_t img_base)
{
PIMAGE_IMPORT_BY_NAME ord;
addr_t addr;
*iat=0;
if ( thunk->u1.AddressOfData == 0 )
break;
if ( thunk->u1.Ordinal & IMAGE_ORDINAL_FLAG )
{
// printf(" %4u\n", thunk->u1.Ordinal & 0xFFFF);
u16_t ordinal;
ordinal = thunk->u1.Ordinal & 0xFFFF;
*iat = functions[ordinal-exp->Base] + exp_dll->img_base;
break;
}
else
{
ord = MakePtr(PIMAGE_IMPORT_BY_NAME,
thunk->u1.AddressOfData, img_base);
*iat=0;
DBG("import %s", ord->Name);
DBG("import %s ", ord->Name);
if(strncmp(ord->Name,
MakePtr(char*,funcname[ord->Hint],exp_dll->img_base),32))
@ -639,7 +657,7 @@ bool link_pe(addr_t img_base)
{
u16_t ordinal;
ordinal = ordinals[ind];
DBG(" \t\tat %x\n", functions[ordinal] + exp_dll->img_base);
DBG("ordinal %d\t\tat %x\n", ordinal, functions[ordinal] + exp_dll->img_base);
*iat = functions[ordinal] + exp_dll->img_base;
break;
};

View File

@ -3,7 +3,7 @@
.section .drectve
.ascii " -export:CreateImage" # cdecl
# .ascii " -export:CreateImage" # cdecl
.ascii " -export:LoadFile" # stdcall
.ascii " -export:Kmalloc" # eax FIXME

View File

@ -32,20 +32,20 @@ init_heap:
sub eax, 4096
ret
@@:
mov esi, [ebx+APPDATA.mem_size]
add esi, 4095
and esi, not 4095
mov [ebx+APPDATA.mem_size], esi
mov edx, [ebx+APPDATA.mem_size]
add edx, 4095
and edx, not 4095
mov [ebx+APPDATA.mem_size], edx
mov eax, HEAP_TOP
mov [ebx+APPDATA.heap_base], esi
mov [ebx+APPDATA.heap_base], edx
mov [ebx+APPDATA.heap_top], eax
sub eax, esi
shr esi, 10
sub eax, edx
shr edx, 10
mov ecx, eax
sub eax, 4096
or ecx, FREE_BLOCK
mov [page_tabs+esi], ecx
mov [page_tabs+edx], ecx
ret
align 4

View File

@ -40,7 +40,6 @@ static inline void sec_clear(addr_t dst, size_t len)
int __stdcall strncmp(const char *s1, const char *s2, size_t n);
void __export create_image(addr_t img_base, addr_t raw) asm ("CreateImage");
bool link_image(addr_t img_base);
md_t* __fastcall load_image(const char *path);
@ -59,7 +58,7 @@ void* __fastcall load_pe(const char *path)
};
*/
bool validate_pe(void *raw, size_t raw_size)
bool validate_pe(void *raw, size_t raw_size, bool is_exec)
{
PIMAGE_DOS_HEADER dos;
PIMAGE_NT_HEADERS32 nt;
@ -80,9 +79,18 @@ bool validate_pe(void *raw, size_t raw_size)
if(nt->Signature != IMAGE_NT_SIGNATURE)
return false;
if(nt->FileHeader.Machine != IMAGE_FILE_MACHINE_I386)
return false;
if(is_exec && (nt->FileHeader.Characteristics & IMAGE_FILE_DLL))
return false;
if(nt->OptionalHeader.Magic != IMAGE_NT_OPTIONAL_HDR32_MAGIC)
return false;
if( is_exec && nt->OptionalHeader.ImageBase != 0)
return false;
if(nt->OptionalHeader.SectionAlignment < PAGE_SIZE)
{
if(nt->OptionalHeader.FileAlignment != nt->OptionalHeader.SectionAlignment)
@ -127,7 +135,7 @@ md_t* __fastcall load_image(const char *path)
return NULL;
};
if( ! validate_pe(raw, raw_size) )
if( ! validate_pe(raw, raw_size, false) )
{
DBG("invalid pe file %s\n", path);
mem_free(raw);
@ -150,7 +158,7 @@ md_t* __fastcall load_image(const char *path)
img_base = img_md->base;
create_image(img_base, (addr_t)raw);
create_image(img_base, (addr_t)raw, true);
mem_free(raw);
@ -190,7 +198,7 @@ addr_t get_proc_addr(addr_t module, char *name)
*/
void create_image(addr_t img_base, addr_t raw)
void create_image(addr_t img_base, addr_t raw, bool force_clear)
{
PIMAGE_DOS_HEADER dos;
PIMAGE_NT_HEADERS32 nt;
@ -223,13 +231,16 @@ void create_image(addr_t img_base, addr_t raw)
if(img_sec->SizeOfRawData)
sec_copy(dest_ptr, src_ptr, img_sec->SizeOfRawData);
if(force_clear)
{
sec_size = (img_sec->Misc.VirtualSize + sec_align -1) & -sec_align;
if(sec_size > img_sec->SizeOfRawData)
sec_clear(dest_ptr + img_sec->SizeOfRawData,
sec_size - img_sec->SizeOfRawData);
};
img_sec++;
}
};
if(nt->OptionalHeader.DataDirectory[5].Size)
{

View File

@ -146,11 +146,12 @@ proc mnt_exec stdcall file_base:dword, file_size:dword, \
test al, al
jnz @b
lea edi, [cmdline]
mov dword [edi],0
mov esi, [cmd_line]
test esi, esi
jz .no_cmdline
lea edi, [cmdline]
lea ecx, [edi+255]
mov [edi+252], dword 0
@@:
@ -226,8 +227,8 @@ proc mnt_exec stdcall file_base:dword, file_size:dword, \
mov ecx, [hdr_mem]
mov edi, [file_size]
add edi, 4095
and edi, not 4095
; add edi, 4095
; and edi, not 4095
sub ecx, edi
jna @F
@ -246,8 +247,8 @@ proc mnt_exec stdcall file_base:dword, file_size:dword, \
mov eax, [save_cr3]
call set_cr3
mov [application_table_status], 0 ;unlock application_table_status mutex
mov eax,[process_number] ;set result
mov [application_table_status], 0 ;unlock application_table_status mutex
pop edi
pop esi
@ -433,8 +434,8 @@ proc pe_app_param stdcall path:dword, raw:dword, ex_pg_dir:dword, ex_stack:dword
DEBUGF 1,"%s",new_process_running
.err:
mov [application_table_status], 0 ;unlock application_table_status mutex
mov eax,[process_number] ;set result
mov [application_table_status], 0 ;unlock application_table_status mutex
pop edi
pop esi

View File

@ -3402,9 +3402,9 @@ IPC
* ebx = 㪠§ â¥«ì ­  ¨§®¡à ¦¥­¨¥
* ecx = [à §¬¥à ¯® ®á¨ x]*65536 + [à §¬¥à ¯® ®á¨ y]
* edx = [ª®®à¤¨­ â  ¯® ®á¨ x]*65536 + [ª®®à¤¨­ â  ¯® ®á¨ y]
* esi = ç¨á«® ¡¨â ­  ¯¨ªá¥«ì, ¤®«¦­® ¡ëâì 8, 16, 24 ¨«¨ 32
* edi = 㪠§ â¥«ì ­  ¯ «¨âàã (256 梥⮢ 0x00RRGGBB);
¨£­®à¨àã¥âáï ¯à¨ esi = 16, 24 ¨ 32
* esi = ç¨á«® ¡¨â ­  ¯¨ªá¥«ì, ¤®«¦­® ¡ëâì 1, 4, 8, 15, 16, 24 ¨«¨ 32
* edi = 㪠§ â¥«ì ­  ¯ «¨âàã (2 ¢ á⥯¥­¨ esi 梥⮢ 0x00RRGGBB);
¨£­®à¨àã¥âáï ¯à¨ esi > 8
* ebp = ᬥ饭¨¥ ¤ ­­ëå ª ¦¤®© á«¥¤ãî饩 áâப¨ ¨§®¡à ¦¥­¨ï
®â­®á¨â¥«ì­® ¯à¥¤ë¤ã饩
‚®§¢à é ¥¬®¥ §­ ç¥­¨¥:
@ -3413,13 +3413,23 @@ IPC
* Š®®à¤¨­ âë ¨§®¡à ¦¥­¨ï - íâ® ª®®à¤¨­ âë ¢¥àå­¥£® «¥¢®£® 㣫 
¨§®¡à ¦¥­¨ï ®â­®á¨â¥«ì­® ®ª­ .
* <20> §¬¥à ¨§®¡à ¦¥­¨ï ¢ ¡ ©â å ¥áâì xsize*ysize.
* ”®à¬ â ¨§®¡à ¦¥­¨ï á 1 ¡¨â®¬ ­  ¯¨ªá¥«ì: ª ¦¤ë© ¡ ©â ¨§®¡à ¦¥­¨ï,
§  ¨áª«î祭¨¥¬, ¡ëâì ¬®¦¥â, ¯®á«¥¤­¨å ¡ ©â®¢ áâப, ᮤ¥à¦¨â
¨­ä®à¬ æ¨î ® 梥⥠8 ¯¨ªá¥«¥©, áâ à訩 ¡¨â ᮮ⢥âáâ¢ã¥â ¯¥à¢®¬ã
¯¨ªá¥«î.
* ”®à¬ â ¨§®¡à ¦¥­¨ï á 4 ¡¨â ¬¨ ­  ¯¨ªá¥«ì: ª ¦¤ë© ¡ ©â ¨§®¡à ¦¥­¨ï,
§  ¨áª«î祭¨¥¬ ¯®á«¥¤­¨å ¡ ©â®¢ áâப (¥á«¨ è¨à¨­  ¨§®¡à ¦¥­¨ï
­¥çñâ­ ), ᮤ¥à¦¨â ¨­ä®à¬ æ¨î ® 梥⥠2 ¯¨ªá¥«¥©, áâ àè ï â¥âà ¤ 
ᮮ⢥âáâ¢ã¥â ¯¥à¢®¬ã ¯¨ªá¥«î.
* ”®à¬ â ¨§®¡à ¦¥­¨ï á 8 ¡¨â ¬¨ ­  ¯¨ªá¥«ì: ª ¦¤ë© ¡ ©â ¨§®¡à ¦¥­¨ï
à áᬠâਢ ¥âáï ª ª ¨­¤¥ªá ¢ ¯ «¨âà¥.
* …᫨ ¨§®¡à ¦¥­¨¥ ¨á¯®«ì§ã¥â ­¥ ¢á¥ 256 梥⮢,   ¬¥­ìè¥,
à §¬¥à ¯ «¨âàë ¬®¦¥â ¡ëâì ¬¥­ìè¥ 256.
* ”®à¬ â ¨§®¡à ¦¥­¨ï á 16 ¡¨â ¬¨ ­  ¯¨ªá¥«ì: 梥⠪ ¦¤®£® ¯¨ªá¥«ï
* ”®à¬ â ¨§®¡à ¦¥­¨ï á 15 ¡¨â ¬¨ ­  ¯¨ªá¥«ì: 梥⠪ ¦¤®£® ¯¨ªá¥«ï
ª®¤¨àã¥âáï ª ª (¢ ¡¨â®¢®¬ ¯à¥¤áâ ¢«¥­¨¨) 0RRRRRGGGGGBBBBB -
¯® 5 ¯¨ªá¥«¥© ­  ª ¦¤ë© 梥â.
* ”®à¬ â ¨§®¡à ¦¥­¨ï á 16 ¡¨â ¬¨ ­  ¯¨ªá¥«ì: 梥⠪ ¦¤®£® ¯¨ªá¥«ï
ª®¤¨àã¥âáï ª ª RRRRRGGGGGGBBBBB (á奬  5+6+5).
* ”®à¬ â ¨§®¡à ¦¥­¨ï á 24 ¡¨â ¬¨ ­  ¯¨ªá¥«ì: 梥⠪ ¦¤®£® ¯¨ªá¥«ï
ª®¤¨àã¥âáï âà¥¬ï ¡ ©â ¬¨ - ¯®á«¥¤®¢ â¥«ì­® ᨭïï, §¥«ñ­ ï,
ªà á­ ï á®áâ ¢«ïî騥 梥â .

View File

@ -1195,61 +1195,185 @@ devices:
dd (0x5D4D shl 16)+VID_ATI, init_r200 ;R480 X850
dd (0x5D52 shl 16)+VID_ATI, init_r200 ;R480 X850
dd (0x791E shl 16)+VID_ATI, init_r500 ;RS690 X1200
dd (0x7140 shl 16)+VID_ATI, init_r500 ;RV515 X1300
dd (0x7142 shl 16)+VID_ATI, init_r500 ;RV515 X1300
dd (0x7146 shl 16)+VID_ATI, init_r500 ;RV515 X1300
dd (0x714D shl 16)+VID_ATI, init_r500 ;RV515 X1300
dd (0x714E shl 16)+VID_ATI, init_r500 ;RV515 X1300
dd (0x7183 shl 16)+VID_ATI, init_r500 ;RV515 X1300
dd (0x7187 shl 16)+VID_ATI, init_r500 ;RV515 X1300
dd (0x718F shl 16)+VID_ATI, init_r500 ;RV515 X1300
dd (0x7143 shl 16)+VID_ATI, init_r500 ;RV515 X1550
dd (0x7147 shl 16)+VID_ATI, init_r500 ;RV515 X1550
dd (0x715F shl 16)+VID_ATI, init_r500 ;RV515 X1550
dd (0x7193 shl 16)+VID_ATI, init_r500 ;RV515 X1550
dd (0x719F shl 16)+VID_ATI, init_r500 ;RV515 X1550
dd (0x71C0 shl 16)+VID_ATI, init_r500 ;RV530 X1600
dd (0x71C1 shl 16)+VID_ATI, init_r500 ;RV535 X1650
dd (0x71C2 shl 16)+VID_ATI, init_r500 ;RV530 X1600
dd (0x71C3 shl 16)+VID_ATI, init_r500 ;RV535 X1600
dd (0x71C6 shl 16)+VID_ATI, init_r500 ;RV530 X1600
dd (0x71C7 shl 16)+VID_ATI, init_r500 ;RV534 X1650
dd (0x7181 shl 16)+VID_ATI, init_r500 ;RV515 X1600
dd (0x71CD shl 16)+VID_ATI, init_r500 ;RV530 X1600
dd (0x7291 shl 16)+VID_ATI, init_r500 ;R580 X1650
dd (0x7293 shl 16)+VID_ATI, init_r500 ;R580 X1650
dd (0x7100 shl 16)+VID_ATI, init_r500 ;RV520 X1800
dd (0x7109 shl 16)+VID_ATI, init_r500 ;RV520 X1800
dd (0x710A shl 16)+VID_ATI, init_r500 ;RV520 X1800 GTO
dd (0x7249 shl 16)+VID_ATI, init_r500 ;RV580 X1900
dd (0x724B shl 16)+VID_ATI, init_r500 ;RV580 X1900 GT
dd (0x7240 shl 16)+VID_ATI, init_r500 ;RV580 X1950
dd (0x7244 shl 16)+VID_ATI, init_r500 ;RV580 X1950
dd (0x7248 shl 16)+VID_ATI, init_r500 ;RV580 X1950
dd (0x7288 shl 16)+VID_ATI, init_r500 ;R580 X1950 GT
dd (0x7280 shl 16)+VID_ATI, init_r500 ;R580 X1950 PRO
dd (0x94C3 shl 16)+VID_ATI, init_r500 ;RV610 HD 2400 PRO
dd (0x94C1 shl 16)+VID_ATI, init_r500 ;RV610 HD 2400 XT
dd (0x9589 shl 16)+VID_ATI, init_r500 ;RV630 HD 2600 PRO
dd (0x958A shl 16)+VID_ATI, init_r500 ;RV630 HD 2600 X2
dd (0x9588 shl 16)+VID_ATI, init_r500 ;RV630 HD 2600 XT
dd (0x9403 shl 16)+VID_ATI, init_r500 ;R600 HD 2900 PRO
dd (0x9409 shl 16)+VID_ATI, init_r500 ;R600 HD 2900 XT
dd (0x7100 shl 16)+VID_ATI, init_r500 ;Radeon X1800
dd (0x7101 shl 16)+VID_ATI, init_r500 ;Mobility Radeon X1800 XT
dd (0x7102 shl 16)+VID_ATI, init_r500 ;Mobility Radeon X1800
dd (0x7103 shl 16)+VID_ATI, init_r500 ;Mobility FireGL V7200
dd (0x7104 shl 16)+VID_ATI, init_r500 ;FireGL V7200
dd (0x7105 shl 16)+VID_ATI, init_r500 ;FireGL V5300
dd (0x7106 shl 16)+VID_ATI, init_r500 ;Mobility FireGL V7100
dd (0x7108 shl 16)+VID_ATI, init_r500 ;Radeon X1800
dd (0x7109 shl 16)+VID_ATI, init_r500 ;Radeon X1800
dd (0x710A shl 16)+VID_ATI, init_r500 ;Radeon X1800
dd (0x710B shl 16)+VID_ATI, init_r500 ;Radeon X1800
dd (0x710C shl 16)+VID_ATI, init_r500 ;Radeon X1800
dd (0x710E shl 16)+VID_ATI, init_r500 ;FireGL V7300
dd (0x710F shl 16)+VID_ATI, init_r500 ;FireGL V7350
dd (0x7140 shl 16)+VID_ATI, init_r500 ;Radeon X1600/X1550
dd (0x7141 shl 16)+VID_ATI, init_r500 ;RV505
dd (0x7142 shl 16)+VID_ATI, init_r500 ;Radeon X1300/X1550
dd (0x7143 shl 16)+VID_ATI, init_r500 ;Radeon X1550
dd (0x7144 shl 16)+VID_ATI, init_r500 ;M54-GL
dd (0x7145 shl 16)+VID_ATI, init_r500 ;Mobility Radeon X1400
dd (0x7146 shl 16)+VID_ATI, init_r500 ;Radeon X1300/X1550
dd (0x7147 shl 16)+VID_ATI, init_r500 ;Radeon X1550 64-bit
dd (0x7149 shl 16)+VID_ATI, init_r500 ;Mobility Radeon X1300
dd (0x714A shl 16)+VID_ATI, init_r500 ;Mobility Radeon X1300
dd (0x714B shl 16)+VID_ATI, init_r500 ;Mobility Radeon X1300
dd (0x714C shl 16)+VID_ATI, init_r500 ;Mobility Radeon X1300
dd (0x714D shl 16)+VID_ATI, init_r500 ;Radeon X1300
dd (0x714E shl 16)+VID_ATI, init_r500 ;Radeon X1300
dd (0x714F shl 16)+VID_ATI, init_r500 ;RV505
dd (0x7151 shl 16)+VID_ATI, init_r500 ;RV505
dd (0x7152 shl 16)+VID_ATI, init_r500 ;FireGL V3300
dd (0x7153 shl 16)+VID_ATI, init_r500 ;FireGL V3350
dd (0x715E shl 16)+VID_ATI, init_r500 ;Radeon X1300
dd (0x715F shl 16)+VID_ATI, init_r500 ;Radeon X1550 64-bit
dd (0x7180 shl 16)+VID_ATI, init_r500 ;Radeon X1300/X1550
dd (0x7181 shl 16)+VID_ATI, init_r500 ;Radeon X1600
dd (0x7183 shl 16)+VID_ATI, init_r500 ;Radeon X1300/X1550
dd (0x7186 shl 16)+VID_ATI, init_r500 ;Mobility Radeon X1450
dd (0x7187 shl 16)+VID_ATI, init_r500 ;Radeon X1300/X1550
dd (0x7188 shl 16)+VID_ATI, init_r500 ;Mobility Radeon X2300
dd (0x718A shl 16)+VID_ATI, init_r500 ;Mobility Radeon X2300
dd (0x718B shl 16)+VID_ATI, init_r500 ;Mobility Radeon X1350
dd (0x718C shl 16)+VID_ATI, init_r500 ;Mobility Radeon X1350
dd (0x718D shl 16)+VID_ATI, init_r500 ;Mobility Radeon X1450
dd (0x718F shl 16)+VID_ATI, init_r500 ;Radeon X1300
dd (0x7193 shl 16)+VID_ATI, init_r500 ;Radeon X1550
dd (0x7196 shl 16)+VID_ATI, init_r500 ;Mobility Radeon X1350
dd (0x719B shl 16)+VID_ATI, init_r500 ;FireMV 2250
dd (0x719F shl 16)+VID_ATI, init_r500 ;Radeon X1550 64-bit
dd (0x71C0 shl 16)+VID_ATI, init_r500 ;Radeon X1600
dd (0x71C1 shl 16)+VID_ATI, init_r500 ;Radeon X1650
dd (0x71C2 shl 16)+VID_ATI, init_r500 ;Radeon X1600
dd (0x71C3 shl 16)+VID_ATI, init_r500 ;Radeon X1600
dd (0x71C4 shl 16)+VID_ATI, init_r500 ;Mobility FireGL V5200
dd (0x71C5 shl 16)+VID_ATI, init_r500 ;Mobility Radeon X1600
dd (0x71C6 shl 16)+VID_ATI, init_r500 ;Radeon X1650
dd (0x71C7 shl 16)+VID_ATI, init_r500 ;Radeon X1650
dd (0x71CD shl 16)+VID_ATI, init_r500 ;Radeon X1600
dd (0x71CE shl 16)+VID_ATI, init_r500 ;Radeon X1300 XT/X1600 Pro
dd (0x71D2 shl 16)+VID_ATI, init_r500 ;FireGL V3400
dd (0x71D4 shl 16)+VID_ATI, init_r500 ;Mobility FireGL V5250
dd (0x71D5 shl 16)+VID_ATI, init_r500 ;Mobility Radeon X1700
dd (0x71D6 shl 16)+VID_ATI, init_r500 ;Mobility Radeon X1700 XT
dd (0x71DA shl 16)+VID_ATI, init_r500 ;FireGL V5200
dd (0x71DE shl 16)+VID_ATI, init_r500 ;Mobility Radeon X1700
dd (0x7200 shl 16)+VID_ATI, init_r500 ;Radeon X2300HD
dd (0x7210 shl 16)+VID_ATI, init_r500 ;Mobility Radeon HD 2300
dd (0x7211 shl 16)+VID_ATI, init_r500 ;Mobility Radeon HD 2300
dd (0x7240 shl 16)+VID_ATI, init_r500 ;Radeon X1950
dd (0x7243 shl 16)+VID_ATI, init_r500 ;Radeon X1900
dd (0x7244 shl 16)+VID_ATI, init_r500 ;Radeon X1950
dd (0x7245 shl 16)+VID_ATI, init_r500 ;Radeon X1900
dd (0x7246 shl 16)+VID_ATI, init_r500 ;Radeon X1900
dd (0x7247 shl 16)+VID_ATI, init_r500 ;Radeon X1900
dd (0x7248 shl 16)+VID_ATI, init_r500 ;Radeon X1900
dd (0x7249 shl 16)+VID_ATI, init_r500 ;Radeon X1900
dd (0x724A shl 16)+VID_ATI, init_r500 ;Radeon X1900
dd (0x724B shl 16)+VID_ATI, init_r500 ;Radeon X1900
dd (0x724C shl 16)+VID_ATI, init_r500 ;Radeon X1900
dd (0x724D shl 16)+VID_ATI, init_r500 ;Radeon X1900
dd (0x724E shl 16)+VID_ATI, init_r500 ;AMD Stream Processor
dd (0x724F shl 16)+VID_ATI, init_r500 ;Radeon X1900
dd (0x7280 shl 16)+VID_ATI, init_r500 ;Radeon X1950
dd (0x7281 shl 16)+VID_ATI, init_r500 ;RV560
dd (0x7283 shl 16)+VID_ATI, init_r500 ;RV560
dd (0x7284 shl 16)+VID_ATI, init_r500 ;Mobility Radeon X1900
dd (0x7287 shl 16)+VID_ATI, init_r500 ;RV560
dd (0x7288 shl 16)+VID_ATI, init_r500 ;Radeon X1950 GT
dd (0x7289 shl 16)+VID_ATI, init_r500 ;RV570
dd (0x728B shl 16)+VID_ATI, init_r500 ;RV570
dd (0x728C shl 16)+VID_ATI, init_r500 ;ATI FireGL V7400
dd (0x7290 shl 16)+VID_ATI, init_r500 ;RV560
dd (0x7291 shl 16)+VID_ATI, init_r500 ;Radeon X1650
dd (0x7293 shl 16)+VID_ATI, init_r500 ;Radeon X1650
dd (0x7297 shl 16)+VID_ATI, init_r500 ;RV560
dd (0x791E shl 16)+VID_ATI, init_r500 ;Radeon X1200
dd (0x791F shl 16)+VID_ATI, init_r500 ;Radeon X1200
dd (0x793F shl 16)+VID_ATI, init_r500 ;Radeon Xpress 1200
dd (0x7941 shl 16)+VID_ATI, init_r500 ;Radeon Xpress 1200
dd (0x7942 shl 16)+VID_ATI, init_r500 ;Radeon Xpress 1200 (M)
dd (0x796C shl 16)+VID_ATI, init_r500 ;RS740
dd (0x796D shl 16)+VID_ATI, init_r500 ;RS740M
dd (0x796E shl 16)+VID_ATI, init_r500 ;ATI Radeon 2100 RS740
dd (0x796F shl 16)+VID_ATI, init_r500 ;RS740M
dd (0x9400 shl 16)+VID_ATI, init_r500 ;Radeon HD 2900 XT
dd (0x9401 shl 16)+VID_ATI, init_r500 ;Radeon HD 2900 XT
dd (0x9402 shl 16)+VID_ATI, init_r500 ;Radeon HD 2900 XT
dd (0x9403 shl 16)+VID_ATI, init_r500 ;Radeon HD 2900 Pro
dd (0x9405 shl 16)+VID_ATI, init_r500 ;Radeon HD 2900 GT
dd (0x940A shl 16)+VID_ATI, init_r500 ;FireGL V8650
dd (0x940B shl 16)+VID_ATI, init_r500 ;FireGL V8600
dd (0x940F shl 16)+VID_ATI, init_r500 ;FireGL V7600
dd (0x94C0 shl 16)+VID_ATI, init_r500 ;RV610
dd (0x94C1 shl 16)+VID_ATI, init_r500 ;Radeon HD 2400 XT
dd (0x94C3 shl 16)+VID_ATI, init_r500 ;Radeon HD 2400 Pro
dd (0x94C4 shl 16)+VID_ATI, init_r500 ;ATI Radeon HD 2400 PRO AGP
dd (0x94C5 shl 16)+VID_ATI, init_r500 ;FireGL V4000
dd (0x94C6 shl 16)+VID_ATI, init_r500 ;RV610
dd (0x94C7 shl 16)+VID_ATI, init_r500 ;ATI Radeon HD 2350
dd (0x94C8 shl 16)+VID_ATI, init_r500 ;Mobility Radeon HD 2400 XT
dd (0x94C9 shl 16)+VID_ATI, init_r500 ;Mobility Radeon HD 2400
dd (0x94CB shl 16)+VID_ATI, init_r500 ;ATI RADEON E2400
dd (0x94CC shl 16)+VID_ATI, init_r500 ;ATI Radeon HD 2400
dd (0x9500 shl 16)+VID_ATI, init_r500 ;RV670
dd (0x9501 shl 16)+VID_ATI, init_r500 ;ATI Radeon HD3870
dd (0x9504 shl 16)+VID_ATI, init_r500 ;ATI Mobility Radeon HD 3850
dd (0x9505 shl 16)+VID_ATI, init_r500 ;ATI Radeon HD3850
dd (0x9506 shl 16)+VID_ATI, init_r500 ;ATI Mobility Radeon HD 3850 X2
dd (0x9507 shl 16)+VID_ATI, init_r500 ;RV670
dd (0x9508 shl 16)+VID_ATI, init_r500 ;ATI Mobility Radeon HD 3870
dd (0x9509 shl 16)+VID_ATI, init_r500 ;ATI Mobility Radeon HD 3870 X2
dd (0x950F shl 16)+VID_ATI, init_r500 ;ATI Radeon HD3870 X2
dd (0x9511 shl 16)+VID_ATI, init_r500 ;ATI FireGL V7700
dd (0x9515 shl 16)+VID_ATI, init_r500 ;ATI Radeon HD 3850 AGP
dd (0x9517 shl 16)+VID_ATI, init_r500 ;ATI Radeon HD 3960
dd (0x9519 shl 16)+VID_ATI, init_r500 ;FireStream 9170
dd (0x9580 shl 16)+VID_ATI, init_r500 ;RV630
dd (0x9581 shl 16)+VID_ATI, init_r500 ;Mobility Radeon HD 2600
dd (0x9583 shl 16)+VID_ATI, init_r500 ;Mobility Radeon HD 2600 XT
dd (0x9586 shl 16)+VID_ATI, init_r500 ;ATI Radeon HD 2600 XT AGP
dd (0x9587 shl 16)+VID_ATI, init_r500 ;ATI Radeon HD 2600 Pro AGP
dd (0x9588 shl 16)+VID_ATI, init_r500 ;Radeon HD 2600 XT
dd (0x9589 shl 16)+VID_ATI, init_r500 ;Radeon HD 2600 Pro
dd (0x958A shl 16)+VID_ATI, init_r500 ;Gemini RV630
dd (0x958B shl 16)+VID_ATI, init_r500 ;Gemini ATI Mobility Radeon HD 2600 XT
dd (0x958C shl 16)+VID_ATI, init_r500 ;FireGL V5600
dd (0x958D shl 16)+VID_ATI, init_r500 ;FireGL V3600
dd (0x958E shl 16)+VID_ATI, init_r500 ;ATI Radeon HD 2600 LE
dd (0x958F shl 16)+VID_ATI, init_r500 ;ATI Mobility FireGL Graphics Processor
dd (0x9590 shl 16)+VID_ATI, init_r500 ;ATI Radeon HD 3600 Series
dd (0x9591 shl 16)+VID_ATI, init_r500 ;Mobility Radeon HD 3650
dd (0x9593 shl 16)+VID_ATI, init_r500 ;Mobility Radeon HD 3670
dd (0x9595 shl 16)+VID_ATI, init_r500 ;Mobility FireGL V5700
dd (0x9596 shl 16)+VID_ATI, init_r500 ;ATI Radeon HD 3650 AGP
dd (0x9597 shl 16)+VID_ATI, init_r500 ;ATI Radeon HD 3600 Series
dd (0x9598 shl 16)+VID_ATI, init_r500 ;ATI Radeon HD 3670
dd (0x9599 shl 16)+VID_ATI, init_r500 ;ATI Radeon HD 3600 Series
dd (0x959B shl 16)+VID_ATI, init_r500 ;Mobility FireGL Graphics Processor
dd (0x95C0 shl 16)+VID_ATI, init_r500 ;ATI Radeon HD 3470
dd (0x95C2 shl 16)+VID_ATI, init_r500 ;ATI Mobility Radeon HD 3430 (M82)
dd (0x95C4 shl 16)+VID_ATI, init_r500 ;Mobility Radeon HD 3400 Series (M82)
dd (0x95C5 shl 16)+VID_ATI, init_r500 ;ATI Radeon HD 3450
dd (0x95C7 shl 16)+VID_ATI, init_r500 ;ATI Radeon HD 3430
dd (0x95CC shl 16)+VID_ATI, init_r500 ;Fire PRO Professional Graphics ASIC
dd (0x95CD shl 16)+VID_ATI, init_r500 ;ATI FireMV 2450
dd (0x95CE shl 16)+VID_ATI, init_r500 ;ATI FireMV 2260
dd (0x95CF shl 16)+VID_ATI, init_r500 ;ATI FireMV 2260
dd (0x9610 shl 16)+VID_ATI, init_r500 ;ATI Radeon HD 3200 Graphics
dd (0x9611 shl 16)+VID_ATI, init_r500 ;ATI Radeon 3100 Graphics
dd (0x9612 shl 16)+VID_ATI, init_r500 ;ATI Radeon HD 3200 Graphics
dd (0x9613 shl 16)+VID_ATI, init_r500 ;ATI Radeon 3100 Graphics
dd (0x9614 shl 16)+VID_ATI, init_r500 ;ATI Radeon HD 3300 Graphics
dd (0x9440 shl 16)+VID_ATI, init_r500 ;ATI Radeon 4800 Series
dd (0x9441 shl 16)+VID_ATI, init_r500 ;ATI Radeon 4870 X2
dd (0x9442 shl 16)+VID_ATI, init_r500 ;ATI Radeon 4800 Series
dd (0x9444 shl 16)+VID_ATI, init_r500 ;Everest ATI FirePro Graphics Accelerator
dd (0x9446 shl 16)+VID_ATI, init_r500 ;K2 ATI FirePro Graphics Accelerator
dd (0x944E shl 16)+VID_ATI, init_r500 ;RV770
dd (0x9456 shl 16)+VID_ATI, init_r500 ;Denali ATI FirePro Graphics
dd 0 ;terminator

View File

@ -5,6 +5,10 @@ if 0
The below code is a rework from code in
xf86-video-radeonhd/src/r5xx_accel.c, xf86-video-radeonhd/src/r5xx_xaa.c
git://anongit.freedesktop.org/git/nouveau/xf86-video-radeonhd
git://anongit.freedesktop.org/git/xorg/driver/xf86-video-ati
Copyright 2008 Luc Verhaegen <lverhaegen@novell.com>
Copyright 2008 Matthias Hopf <mhopf@novell.com>
Copyright 2008 Egbert Eich <eich@novell.com>
@ -662,7 +666,7 @@ proc R5xxSetupForSolidFill stdcall,color:dword, rop:dword, planemask:dword
or edx, [rhd.control]
or edx, (R5XX_GMC_BRUSH_SOLID_COLOR or R5XX_GMC_SRC_DATATYPE_COLOR)
; Save for later clipping */
; Save for later clipping
mov [rhd.control_saved], edx
mov eax, 4

View File

@ -0,0 +1,72 @@
Nable 21.05.2008.
This driver is my contribution (or donation) to KolibriOS. This is provided
AS IS in hope it'll be useful, but WITHOUT ANY WARRANTY! No responcibility
for any hardware damage or data loss. Use at your own risk!
;-------------------------------------------------------------------------------
;Changelog:
;-------------------------------------------------------------------------------
v0.2 - DEV_SET(GET)_MASTERVOL functions are unlocked and implemented.
v0.1 - first release.
;-------------------------------------------------------------------------------
;Tiny FAQ for sound driver by Nable for SB16 sound card.
;-------------------------------------------------------------------------------
;What is it?--------------------------------------------------------------------
As you may know there is a sound subsystem ('INFINITY') in KolibriOS.
This subsystem includes mixer and separate interface for soundplayer
program and driver, so player application don't need to know what soundcard
is installed and how to cope with it, all work with card do the driver.
Before this time there were drivers only for AC97 integrated sound, but I
don't have such at home and if I would upgrade my computer with a newest
hardware, with 100% probability integrated sound will be HD Codec, nowadays
AC97 is not actual (2008 year is at calendar). But I'm not planning to upgrade
my computer so much now (and in next 5-6 years), writing the driver for my PCI
ESS Maestro1 card is difficult for me (may be some time later), so I decided
to write a driver for SB16. At first it is easy, there are many working
examples for DOS, there are heaps of good documentation and as an ISA device
SB16 can be programmed through I/O ports (about 5 ports are used), that is
more easy than PCI access. Now, enough lirics, lets go to physics :-)
If you still don't understand what stuff is it, I'll tell this in brief:
with this driver you can play MP3 and WAV music (using AC97SND player) and
sounds (some games and DOSBOX can produce sound output through sound
subsystem) in KolibriOS.
;Yeah! I need sound in Kolibri and I have SB16 card. Whats then?----------------
At first copy my SOUND.OBJ to /sys/drivers at your Kolibri system. Note,
that if you have AC97 card and it's driver started - then new driver won't
run until reboot. Then run BOARD and go to 'user' tab. Then try to run
AC97SND player. At BOARD you will see the following (if you had a proper
card):
|----------------------------|
|detecting hardware... | <- detector startup message
|DSP found at port 220h | <- if you have a proper card, it'll be
|DSP version 4.13 - SB16 | autodetected. Numbers may be different.
|failed to attach IRQ5 | <- don't mention. Old kernels reserve IRQ5
|owner's handler: 0x80D74284 | see below how to fix it.
|----------------------------|
At first, note that DSP version must be 4.xx or higher. Older cards are not
supported in this first release, maybe some time later. If nothing detected
but PNP/BIOS or some other OS detects your card - I'm sorry, it's perverted
PNP card like OPTi16, that is like HD Codec - until you init it through
PCI->ISA bridge (HD Codec of course through PCI->PCI bridge), map it, etc,
you can't use it in any way. I'd rather write a PCI device driver, than
for this extreme perversion. If your card detected and has a proper version
but you see 'failed to attach IRQ' - delete stroke 'mov [irq_owner+4*5],1' from the
file kernel.asm of your kernel source, save it, rebuild kernel, copy new
kernel to /sys/ (did you rename 'kernel' to 'kernel.mnt'? You should do it),
restart kernel (Ctrl+Alt+F12, Home). THE EASIER WAY IS TO USE A NEWER KERNEL,
since SVN802 it's fixed.
Now everything should be OK.
;It works for a part of the second and then stops, but system doesn't hang------
Go to 'config.inc' of my driver and change 'sb_irq_num' value from 5 to 7.
Then save, rebuild driver (compile 'sound.asm'), put 'sound' to /sys/drivers/
(you need to rename file 'sound' to 'sound.obj'), restart kernel and try again
to produce sound.
;-------------------------------------------------------------------------------
Ask your questions at KolibriOS forum: board.kolibrios.org
I'll try to answer you if possible.

View File

@ -432,11 +432,12 @@ file_system_lfn:
push ebx
call _sys_exec
mov [image_of_eax], eax
add esp, 12
mov [image_of_eax], eax
ret
; handlers for devices
; in: ecx = 0 => query virtual directory /xxx
; in: ecx = partition number

View File

@ -46,6 +46,10 @@ typedef struct _IMAGE_FILE_HEADER
WORD Characteristics;
} IMAGE_FILE_HEADER, *PIMAGE_FILE_HEADER;
#define IMAGE_FILE_DLL 0x2000
#define IMAGE_FILE_MACHINE_I386 0x014c /* Intel 386 or later processors
and compatible processors */
typedef struct _IMAGE_DATA_DIRECTORY {
DWORD VirtualAddress;
DWORD Size;
@ -192,12 +196,13 @@ extern dll_t core_dll;
#define MakePtr( cast, ptr, addValue ) (cast)( (addr_t)(ptr) + (addr_t)(addValue) )
bool validate_pe(void *raw, size_t raw_size, bool is_exec);
dll_t * find_dll(link_t *list, const char *name);
md_t* __fastcall load_image(const char *path);
void __export create_image(addr_t img_base, addr_t image) asm ("CreateImage");
void create_image(addr_t img_base, addr_t raw, bool force_clear) asm ("CreateImage");

View File

@ -4314,12 +4314,42 @@ sys_putimage_palette:
add dx, word [eax+SLOT_BASE+APPDATA.wnd_clientbox.left]
rol edx, 16
.forced:
cmp esi, 1
jnz @f
push edi
mov eax, [edi+4]
sub eax, [edi]
push eax
push dword [edi]
push 0ffffff80h
mov edi, esp
call put_mono_image
add esp, 12
pop edi
ret
@@:
cmp esi, 4
jnz @f
push edi
push 0ffffff80h
mov edi, esp
call put_4bit_image
pop eax
pop edi
ret
@@:
push ebp esi ebp
cmp esi, 8
jnz @f
mov ebp, putimage_get8bpp
mov esi, putimage_init8bpp
jmp sys_putimage_bpp
@@:
cmp esi, 15
jnz @f
mov ebp, putimage_get15bpp
mov esi, putimage_init15bpp
jmp sys_putimage_bpp
@@:
cmp esi, 16
jnz @f
@ -4342,15 +4372,28 @@ sys_putimage_palette:
pop ebp esi ebp
ret
put_mono_image:
push ebp esi ebp
mov ebp, putimage_get1bpp
mov esi, putimage_init1bpp
jmp sys_putimage_bpp
put_4bit_image:
push ebp esi ebp
mov ebp, putimage_get4bpp
mov esi, putimage_init4bpp
jmp sys_putimage_bpp
putimage_init24bpp:
lea eax, [eax*3]
putimage_init8bpp:
ret
align 16
putimage_get24bpp:
mov eax, [esi]
add esi, 3
ret 4
align 16
putimage_get8bpp:
movzx eax, byte [esi]
push edx
@ -4360,17 +4403,79 @@ putimage_get8bpp:
inc esi
ret 4
putimage_init1bpp:
add eax, ecx
push ecx
add eax, 7
add ecx, 7
shr eax, 3
shr ecx, 3
sub eax, ecx
pop ecx
ret
align 16
putimage_get1bpp:
push edx
mov edx, [esp+8]
mov al, [edx]
add al, al
jnz @f
lodsb
adc al, al
@@:
mov [edx], al
sbb eax, eax
and eax, [edx+8]
add eax, [edx+4]
pop edx
ret 4
putimage_init4bpp:
add eax, ecx
push ecx
add ecx, 1
add eax, 1
shr ecx, 1
shr eax, 1
sub eax, ecx
pop ecx
ret
align 16
putimage_get4bpp:
push edx
mov edx, [esp+8]
add byte [edx], 80h
jc @f
movzx eax, byte [edx+1]
mov edx, [edx+4]
and eax, 0x0F
mov eax, [edx+eax*4]
pop edx
ret 4
@@:
movzx eax, byte [esi]
add esi, 1
mov [edx+1], al
shr eax, 4
mov edx, [edx+4]
mov eax, [edx+eax*4]
pop edx
ret 4
putimage_init32bpp:
shl eax, 2
ret
align 16
putimage_get32bpp:
lodsd
ret 4
putimage_init15bpp:
putimage_init16bpp:
add eax, eax
ret
putimage_get16bpp:
align 16
putimage_get15bpp:
; 0RRRRRGGGGGBBBBB -> 00000000RRRRR000GGGGG000BBBBB000
push ecx edx
movzx eax, word [esi]
@ -4386,7 +4491,26 @@ putimage_get16bpp:
or eax, ecx
or eax, edx
pop edx ecx
ret
ret 4
align 16
putimage_get16bpp:
; RRRRRGGGGGGBBBBB -> 00000000RRRRR000GGGGGG00BBBBB000
push ecx edx
movzx eax, word [esi]
add esi, 2
mov ecx, eax
mov edx, eax
and eax, 0x1F
and ecx, 0x3F shl 5
and edx, 0x1F shl 11
shl eax, 3
shl ecx, 5
shl edx, 8
or eax, ecx
or eax, edx
pop edx ecx
ret 4
; eax x beginning
; ebx y beginning

View File

@ -46,6 +46,7 @@ H_SRC:= \
include/link.h \
include/core.h \
include/mm.h \
include/pe.h \
include/slab.h
PE_OBJS = $(patsubst %.s, bin/%.obj, $(patsubst %.asm, bin/%.obj,\

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
@ -339,7 +339,7 @@ rtl8169_txb rb NUM_TX_DESC * RX_BUF_SIZE
; Define the RX Descriptor
align 256
rtl8169_rx_ring rb NUM_RX_DESC * sizeof.rtl8169_TxDesc
rtl8169_rx_ring rb NUM_RX_DESC * sizeof.rtl8169_RxDesc
; Create a static buffer of size RX_BUF_SZ for each
; RX Descriptor All descriptors point to a
@ -524,20 +524,20 @@ endp
; Also adjust PCI latency timer to a reasonable value, 32.
proc adjust_pci_device
DEBUGF 1,"K : adjust_pci_device\n"
; DEBUGF 1,"K : adjust_pci_device\n"
stdcall pci_read_config_word,PCI_COMMAND
mov bx,ax
or bx,PCI_COMMAND_MASTER or PCI_COMMAND_IO
cmp ax,bx
je @f
DEBUGF 1,"K : adjust_pci_device: The PCI BIOS has not enabled this device!\nK : Updating PCI command %x->%x. pci_bus %x pci_device_fn %x\n",ax,bx,[pci_bus]:2,[pci_dev]:2
; DEBUGF 1,"K : adjust_pci_device: The PCI BIOS has not enabled this device!\nK : Updating PCI command %x->%x. pci_bus %x pci_device_fn %x\n",ax,bx,[pci_bus]:2,[pci_dev]:2
stdcall pci_write_config_word,PCI_COMMAND,ebx
@@:
stdcall pci_read_config_byte,PCI_LATENCY_TIMER
cmp al,32
jae @f
DEBUGF 1,"K : adjust_pci_device: PCI latency timer (CFLT) is unreasonably low at %d.\nK : Setting to 32 clocks.\n",al
; DEBUGF 1,"K : adjust_pci_device: PCI latency timer (CFLT) is unreasonably low at %d.\nK : Setting to 32 clocks.\n",al
stdcall pci_write_config_byte,PCI_LATENCY_TIMER,32
@@:
ret
@ -559,7 +559,7 @@ proc pci_bar_start,index:dword
stdcall pci_read_config_dword,eax
or eax,eax
jz .not64
DEBUGF 1,"K : pci_bar_start: Unhandled 64bit BAR\n"
; DEBUGF 1,"K : pci_bar_start: Unhandled 64bit BAR\n"
add esp,4
or eax,-1
ret
@ -572,7 +572,7 @@ endp
proc rtl8169_init_board
DEBUGF 1,"K : rtl8169_init_board\n"
; DEBUGF 1,"K : rtl8169_init_board\n"
call adjust_pci_device
@ -592,7 +592,7 @@ proc rtl8169_init_board
; identify config method
RTL_R32 RTL8169_REG_TxConfig
and eax,0x7c800000
DEBUGF 1,"K : rtl8169_init_board: TxConfig & 0x7c800000 = 0x%x\n",eax
; DEBUGF 1,"K : rtl8169_init_board: TxConfig & 0x7c800000 = 0x%x\n",eax
mov esi,mac_info-8
@@: add esi,8
mov ecx,eax
@ -625,9 +625,9 @@ proc rtl8169_init_board
jmp .match
@@:
; if unknown chip, assume array element #0, original RTL-8169 in this case
DEBUGF 1,"K : rtl8169_init_board: PCI device: unknown chip version, assuming RTL-8169\n"
; DEBUGF 1,"K : rtl8169_init_board: PCI device: unknown chip version, assuming RTL-8169\n"
RTL_R32 RTL8169_REG_TxConfig
DEBUGF 1,"K : rtl8169_init_board: PCI device: TxConfig = 0x%x\n",eax
; DEBUGF 1,"K : rtl8169_init_board: PCI device: TxConfig = 0x%x\n",eax
mov [rtl8169_tpc.chipset],0
@ -642,7 +642,7 @@ endp
proc rtl8169_hw_PHY_config
DEBUGF 1,"K : rtl8169_hw_PHY_config: priv.mcfg=%d, priv.pcfg=%d\n",[rtl8169_tpc.mcfg],[rtl8169_tpc.pcfg]
; DEBUGF 1,"K : rtl8169_hw_PHY_config: priv.mcfg=%d, priv.pcfg=%d\n",[rtl8169_tpc.mcfg],[rtl8169_tpc.pcfg]
; DBG_PRINT("priv->mcfg=%d, priv->pcfg=%d\n", tpc->mcfg, tpc->pcfg);
@ -705,7 +705,7 @@ proc rtl8169_hw_PHY_config
jmp .exit
.not_2_or_3:
; DBG_PRINT("tpc->mcfg=%d. Discard hw PHY config.\n", tpc->mcfg);
DEBUGF 1,"K : tpc.mcfg=%d, discard hw PHY config\n",[rtl8169_tpc.mcfg]
; DEBUGF 1,"K : tpc.mcfg=%d, discard hw PHY config\n",[rtl8169_tpc.mcfg]
.exit:
ret
endp
@ -716,21 +716,21 @@ endp
proc RTL8169_WRITE_GMII_REG,RegAddr:byte,value:dword
DEBUGF 1,"K : RTL8169_WRITE_GMII_REG: 0x%x 0x%x\n",[RegAddr]:2,[value]
;;; DEBUGF 1,"K : RTL8169_WRITE_GMII_REG: 0x%x 0x%x\n",[RegAddr]:2,[value]
movzx eax,[RegAddr]
shl eax,16
or eax,[value]
or eax,0x80000000
RTL_W32 RTL8169_REG_PHYAR,eax
stdcall udelay,1000
stdcall udelay,1 ;;;1000
mov ecx,2000
; Check if the RTL8169 has completed writing to the specified MII register
@@: RTL_R32 RTL8169_REG_PHYAR
test eax,0x80000000
jz .exit
stdcall udelay,100
stdcall udelay,1 ;;;100
loop @b
.exit:
ret
@ -738,21 +738,21 @@ endp
proc RTL8169_READ_GMII_REG,RegAddr:byte
DEBUGF 1,"K : RTL8169_READ_GMII_REG: 0x%x\n",[RegAddr]:2
;;; DEBUGF 1,"K : RTL8169_READ_GMII_REG: 0x%x\n",[RegAddr]:2
push ecx
movzx eax,[RegAddr]
shl eax,16
; or eax,0x0
RTL_W32 RTL8169_REG_PHYAR,eax
stdcall udelay,1000
stdcall udelay,1 ;;;1000
mov ecx,2000
; Check if the RTL8169 has completed retrieving data from the specified MII register
@@: RTL_R32 RTL8169_REG_PHYAR
test eax,0x80000000
jnz .exit
stdcall udelay,100
stdcall udelay,1 ;;;100
loop @b
or eax,-1
@ -767,7 +767,7 @@ endp
proc rtl8169_set_rx_mode
DEBUGF 1,"K : rtl8169_set_rx_mode\n"
; DEBUGF 1,"K : rtl8169_set_rx_mode\n"
; IFF_ALLMULTI
; Too many to filter perfectly -- accept all multicasts
@ -785,7 +785,7 @@ endp
proc rtl8169_init_ring
DEBUGF 1,"K : rtl8169_init_ring\n"
; DEBUGF 1,"K : rtl8169_init_ring\n"
xor eax,eax
mov [rtl8169_tpc.cur_rx],eax
@ -820,6 +820,7 @@ proc rtl8169_init_ring
mov ecx,NUM_RX_DESC
@@: mov [esi],eax
mov [edi+rtl8169_RxDesc.buf_addr],eax
sub [edi+rtl8169_RxDesc.buf_addr],OS_BASE ; shurf 28.09.2008
mov [edi+rtl8169_RxDesc.status],RTL8169_DSB_OWNbit or RX_BUF_SIZE
add esi,4
add edi,sizeof.rtl8169_RxDesc
@ -833,7 +834,7 @@ endp
proc rtl8169_hw_start
DEBUGF 1,"K : rtl8169_hw_start\n"
; DEBUGF 1,"K : rtl8169_hw_start\n"
; Soft reset the chip
RTL_W8 RTL8169_REG_ChipCmd,RTL8169_CMD_Reset
@ -879,8 +880,14 @@ proc rtl8169_hw_start
RTL_W16 0xE2,0x0000
MOV [rtl8169_tpc.cur_rx],0
RTL_W32 RTL8169_REG_TxDescStartAddr,[rtl8169_tpc.TxDescArray]
RTL_W32 RTL8169_REG_RxDescStartAddr,[rtl8169_tpc.RxDescArray]
push eax ; shurf 28.09.2008
mov eax, [rtl8169_tpc.TxDescArray] ; shurf 28.09.2008
sub eax, OS_BASE ; shurf 28.09.2008
RTL_W32 RTL8169_REG_TxDescStartAddr,eax ;[rtl8169_tpc.TxDescArray] ; shurf 28.09.2008
mov eax, [rtl8169_tpc.RxDescArray] ; shurf 28.09.2008
sub eax, OS_BASE ; shurf 28.09.2008
RTL_W32 RTL8169_REG_RxDescStartAddr,eax ;[rtl8169_tpc.RxDescArray] ; shurf 28.09.2008
pop eax ; shurf 28.09.2008
RTL_W8 RTL8169_REG_Cfg9346,RTL8169_CFG_9346_Lock
stdcall udelay,10
RTL_W32 RTL8169_REG_RxMissed,0
@ -913,7 +920,7 @@ endp
;***************************************************************************
proc rtl8169_probe
DEBUGF 1,"K : rtl8169_probe: 0x%x : 0x%x 0x%x\n",[io_addr]:8,[pci_bus]:2,[pci_dev]:2
; DEBUGF 1,"K : rtl8169_probe: 0x%x : 0x%x 0x%x\n",[io_addr]:8,[pci_bus]:2,[pci_dev]:2
call rtl8169_init_board
@ -928,7 +935,7 @@ proc rtl8169_probe
inc ebx
loop @b
DEBUGF 1,"K : rtl8169_probe: MAC = %x-%x-%x-%x-%x-%x\n",[node_addr+0]:2,[node_addr+1]:2,[node_addr+2]:2,[node_addr+3]:2,[node_addr+4]:2,[node_addr+5]:2
; DEBUGF 1,"K : rtl8169_probe: MAC = %x-%x-%x-%x-%x-%x\n",[node_addr+0]:2,[node_addr+1]:2,[node_addr+2]:2,[node_addr+3]:2,[node_addr+4]:2,[node_addr+5]:2
; Config PHY
stdcall rtl8169_hw_PHY_config
@ -988,7 +995,7 @@ endp
;***************************************************************************
proc rtl8169_reset
DEBUGF 1,"K : rtl8169_reset: 0x%x : 0x%x 0x%x\n",[io_addr]:8,[pci_bus]:2,[pci_dev]:2
; DEBUGF 1,"K : rtl8169_reset: 0x%x : 0x%x 0x%x\n",[io_addr]:8,[pci_bus]:2,[pci_dev]:2
mov [rtl8169_tpc.TxDescArrays],rtl8169_tx_ring
; Tx Desscriptor needs 256 bytes alignment
@ -1033,7 +1040,7 @@ endp
;***************************************************************************
proc rtl8169_transmit
DEBUGF 1,"K : rtl8169_transmit\n" ;: 0x%x : 0x%x 0x%x 0x%x 0x%x\n",[io_addr]:8,edi,bx,ecx,esi
; DEBUGF 1,"K : rtl8169_transmit\n" ;: 0x%x : 0x%x 0x%x 0x%x 0x%x\n",[io_addr]:8,edi,bx,ecx,esi
push ecx edx esi
mov eax,MAX_ETH_FRAME_SIZE
@ -1087,6 +1094,7 @@ proc rtl8169_transmit
add eax,[rtl8169_tpc.TxDescArray]
xchg eax,ebx
mov [ebx + rtl8169_TxDesc.buf_addr],eax
sub [ebx + rtl8169_TxDesc.buf_addr],OS_BASE ; shurf 28.09.2008
mov eax,ecx
cmp eax,ETH_ZLEN
@ -1110,7 +1118,7 @@ proc rtl8169_transmit
jnz @f
stdcall udelay,10
loop @b
DEBUGF 1,"K : rtl8169_transmit: TX Time Out\n"
; DEBUGF 1,"K : rtl8169_transmit: TX Time Out\n"
@@:
ret
@ -1168,7 +1176,7 @@ proc rtl8169_poll
add eax,-4
mov [eth_rx_data_len],ax
DEBUGF 1,"K : rtl8169_poll: data length = %u\n",ax
; DEBUGF 1,"K : rtl8169_poll: data length = %u\n",ax
push eax
mov ecx,eax
@ -1190,9 +1198,10 @@ proc rtl8169_poll
@@: mov [ebx + rtl8169_RxDesc.status],eax
mov [ebx + rtl8169_RxDesc.buf_addr],edx
sub [ebx + rtl8169_RxDesc.buf_addr],OS_BASE ; shurf 28.09.2008
jmp @f
.else:
DEBUGF 1,"K : rtl8169_poll: Rx Error\n"
; DEBUGF 1,"K : rtl8169_poll: Rx Error\n"
; FIXME: shouldn't I reset the status on an error
@@:
inc [rtl8169_tpc.cur_rx]

View File

@ -104,6 +104,7 @@ include "drivers/3c59x.inc"
include "drivers/sis900.inc"
include "drivers/pcnet32.inc"
include "drivers/rtl8169.inc"
include "drivers/forcedeth.inc"
; PCICards
; ========
@ -153,6 +154,7 @@ dd 0x816810ec, rtl8169_probe, rtl8169_reset, rtl8169_poll, rtl8169_transmit, 0
dd 0x816910ec, rtl8169_probe, rtl8169_reset, rtl8169_poll, rtl8169_transmit, 0
dd 0x011616ec, rtl8169_probe, rtl8169_reset, rtl8169_poll, rtl8169_transmit, 0
dd 0x43001186, rtl8169_probe, rtl8169_reset, rtl8169_poll, rtl8169_transmit, 0
dd 0x816710ec, rtl8169_probe, rtl8169_reset, rtl8169_poll, rtl8169_transmit, 0
dd 0x590010b7, e3c59x_probe, e3c59x_reset, e3c59x_poll, e3c59x_transmit, 0
dd 0x592010b7, e3c59x_probe, e3c59x_reset, e3c59x_poll, e3c59x_transmit, 0
@ -200,6 +202,23 @@ dd 0x70161039, SIS900_probe, SIS900_reset, SIS900_poll, SIS900_transmit, 0
;dd 0x08001516, mtd80x_probe, mtd80x_reset, mtd80x_poll, mtd80x_transmit, mtd80x_cable
;dd 0x08911516, mtd80x_probe, mtd80x_reset, mtd80x_poll, mtd80x_transmit, mtd80x_cable
dd 0x006610de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; nVidia Corporation nForce2 Ethernet Controller
dd 0x01c310de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested
dd 0x00D610de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested
dd 0x008610de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested
dd 0x008c10de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested
dd 0x00e610de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested
dd 0x00df10de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested
dd 0x005610de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested
dd 0x005710de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested
dd 0x003710de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested
dd 0x003810de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested
dd 0x026810de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested
dd 0x026910de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested
dd 0x037210de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested
dd 0x037310de, forcedeth_probe, forcedeth_reset, forcedeth_poll, forcedeth_transmit, forcedeth_cable ; not tested
rb PCICARDS_ENTRY_SIZE ; end of list marker, do not remove
endg
@ -334,6 +353,9 @@ endp
; All registers may be destroyed
;
;***************************************************************************
uglobal
ether_IP_handler_cnt dd ?
endg
ether_IP_handler:
mov eax, EMPTY_QUEUE
call dequeue
@ -357,6 +379,9 @@ ether_IP_handler:
cld
rep movsd
; inc [ether_IP_handler_cnt]
; DEBUGF 1, "K : ether_IP_handler (%u)\n", [ether_IP_handler_cnt]
; And finally, place the buffer in the IPRX queue
pop ebx
mov eax, IPIN_QUEUE
@ -443,16 +468,18 @@ eth_rx:
cmp ax, ETHER_ARP
je .is_arp ; It is ARP
DEBUGF 1,"K : eth_rx - dumped (%u)\n", ax
inc [dumped_rx_count]
jmp .exit ; If not IP or ARP, ignore
.is_ip:
DEBUGF 1,"K : eth_rx - IP packet\n"
; DEBUGF 1,"K : eth_rx - IP packet\n"
inc dword [ip_rx_count]
call ether_IP_handler
jmp .exit
.is_arp:
DEBUGF 1,"K : eth_rx - ARP packet\n"
; DEBUGF 1,"K : eth_rx - ARP packet\n"
; At this point, the packet is still in the Ether_buffer
call arp_handler

View File

@ -87,6 +87,10 @@ macro GET_IHL reg, header_addr
}
include "tcp.inc"
include "udp.inc"
include "icmp.inc"
;***************************************************************************
; Function
; ip_rx
@ -114,11 +118,13 @@ local buffer_number dd ?
mov ebx, eax ; ebx=pointer to IP_PACKET
; DEBUGF 1, "K : ip_rx - proto: %u\n", [ebx + IP_PACKET.Protocol]:1
; Validate the IP checksum
mov dx, word[ebx + IP_PACKET.HeaderChecksum]
xchg dh,dl ; Get the checksum in intel format
mov [ebx + IP_PACKET.HeaderChecksum], word 0 ; clear checksum field - need to when
mov [ebx + IP_PACKET.HeaderChecksum], 0 ; clear checksum field - need to when
; recalculating checksum
; this needs two data pointers and two size #.
; 2nd pointer can be of length 0
@ -127,8 +133,12 @@ local buffer_number dd ?
stdcall checksum_jb, ebx, ecx ;buf_ptr, buf_size
cmp dx, ax
; DEBUGF 1, "K : ip_rx - checksums: %x - %x\n", dx, ax
jnz .dump.1 ;if CHECKSUM isn't valid then dump packet
mov edx, ebx ; EDX (IP-BUFFER POINTER) WILL BE USED FOR *_rx HANDLERS BELOW!!!
jnz .dump ;if CHECKSUM isn't valid then dump packet
; DEBUGF 1, "K : ip_rx - dest: %x - %x\n", [ebx + IP_PACKET.DestinationAddress], [stack_ip]
; Validate the IP address, if it isn't broadcast
mov eax, [stack_ip]
@ -137,22 +147,37 @@ local buffer_number dd ?
; If the IP address is 255.255.255.255, accept it
; - it is a broadcast packet, which we need for dhcp
cmp dword[ebx + IP_PACKET.DestinationAddress], 0xffffffff
jne .dump
mov eax, [ebx + IP_PACKET.DestinationAddress]
cmp eax, 0xffffffff
;je @f
;mov ecx, [stack_ip]
;and eax, [subnet_mask]
;and ecx, [subnet_mask]
;cmp eax, ecx
;jne .dump.2
;mov eax, [ebx + IP_PACKET.DestinationAddress]
;or eax, [subnet_mask]
;cmp eax, 0xffffffff
jne .dump.2
@@:
mov al, [ebx + IP_PACKET.VersionAndIHL]
and al, 0x0f ;get IHL(header length)
cmp al, 0x05 ;if IHL!= 5*4(20 bytes)
jnz .dump ;then dump it
; DEBUGF 1, "K : ip_rx - ihl: %x - 05\n", al
jnz .dump.3 ;then dump it
cmp byte[ebx + IP_PACKET.TimeToLive], byte 0
je .dump ;if TTL==0 then dump it
; DEBUGF 1, "K : ip_rx - ttl: %x - 00\n", [ebx + IP_PACKET.TimeToLive]:2
mov ax, word[ebx + IP_PACKET.FlagsAndFragmentOffset]
cmp [ebx + IP_PACKET.TimeToLive], 0
je .dump.4 ;if TTL==0 then dump it
mov ax, [ebx + IP_PACKET.FlagsAndFragmentOffset]
and ax, 0xFFBF ;get flags
; DEBUGF 1, "K : ip_rx - flags: %x - 0000\n", ax
cmp ax, 0 ;if some flags was set then we dump this packet
jnz .dump ;the flags should be used for fragmented packets
jnz .dump.5 ;the flags should be used for fragmented packets
; Check the protocol, and call the appropriate handler
; Each handler will re-use or free the queue buffer as appropriate
@ -161,7 +186,7 @@ local buffer_number dd ?
cmp al , PROTOCOL_TCP
jne .not_tcp
DEBUGF 1,"K : ip_rx - TCP packet\n"
; DEBUGF 1,"K : ip_rx - TCP packet\n"
mov eax, dword[buffer_number]
call tcp_rx
jmp .exit
@ -169,29 +194,48 @@ local buffer_number dd ?
.not_tcp:
cmp al, PROTOCOL_UDP
jne .not_udp
DEBUGF 1,"K : ip_rx - UDP packet\n"
; DEBUGF 1,"K : ip_rx - UDP packet\n"
mov eax, dword[buffer_number]
call udp_rx
jmp .exit
.not_udp:
cmp al , PROTOCOL_ICMP
jne .dump ;protocol ain't supported
cmp al, PROTOCOL_ICMP
jne .dump.6 ;protocol ain't supported
DEBUGF 1,"K : ip_rx - ICMP packet\n"
; DEBUGF 1,"K : ip_rx - ICMP packet\n"
;GET_IHL ecx, ebx + IP_PACKET.VersionAndIHL ;get packet length in ecx
mov eax, dword[buffer_number]
stdcall icmp_rx,eax,ebx,ecx ;buffer_number,IPPacketBase,IPHeaderLength
jmp .exit
.dump:
; No protocol handler available, so
; silently dump the packet, freeing up the queue buffer
.dump.1:
DEBUGF 1, "K : ip_rx - dumped (checksum: 0x%x-0x%x)\n", dx, ax
jmp .dump.x
inc dword [dumped_rx_count]
.dump.2:
DEBUGF 1, "K : ip_rx - dumped (ip: %u.%u.%u.%u)\n", [ebx + IP_PACKET.DestinationAddress + 0]:1, [ebx + IP_PACKET.DestinationAddress + 1]:1, [ebx + IP_PACKET.DestinationAddress + 2]:1, [ebx + IP_PACKET.DestinationAddress + 3]:1
jmp .dump.x
mov eax, dword[buffer_number]
.dump.3:
DEBUGF 1, "K : ip_rx - dumped (ihl: %u)\n", al
jmp .dump.x
.dump.4:
DEBUGF 1, "K : ip_rx - dumped (ihl: %u)\n", [ebx + IP_PACKET.TimeToLive]
jmp .dump.x
.dump.5:
DEBUGF 1, "K : ip_rx - dumped (flags: 0x%x)\n", ax
jmp .dump.x
.dump.6:
DEBUGF 1, "K : ip_rx - dumped (proto: %u)\n", [ebx + IP_PACKET.Protocol]:1
.dump.x:
inc dword[dumped_rx_count]
mov eax, [buffer_number]
call freeBuff
.exit:

View File

@ -43,18 +43,19 @@ $Revision$
; all other registers preserved
; This always works, so no error returned
;***************************************************************************
uglobal
freeBuff_cnt dd ?
endg
freeBuff:
; inc [freeBuff_cnt]
; DEBUGF 1, "K : freeBuff (%u)\n", [freeBuff_cnt]
push ebx
push ecx
mov ebx, EMPTY_QUEUE
shl ebx, 1
add ebx, queues
mov ebx, queues + EMPTY_QUEUE * 2
cli ; Ensure that another process does not interfer
movzx ecx, word [ebx]
mov cx, [ebx]
mov [ebx], ax
shl eax, 1
add eax, queueList
mov [eax], cx
mov [queueList + eax * 2], cx
sti
pop ecx
pop ebx
@ -105,7 +106,12 @@ qs_exit:
; all other registers preserved
; This always works, so no error returned
;***************************************************************************
uglobal
queue_cnt dd ?
endg
queue:
; inc [queue_cnt]
; DEBUGF 1, "K : queue (%u)\n", [queue_cnt]
push ebx
shl ebx, 1
add ebx, queueList ; eax now holds address of queue entry
@ -155,6 +161,9 @@ qu_exit:
; all other registers preserved
;
;***************************************************************************
uglobal
dequeue_cnt dd ?
endg
dequeue:
push ebx
shl eax, 1
@ -164,6 +173,8 @@ dequeue:
movzx eax, word [eax]
cmp ax, NO_BUFFER
je dq_exit
; inc [dequeue_cnt]
; DEBUGF 1, "K : dequeue (%u)\n", [dequeue_cnt]
push eax
shl eax, 1
add eax, queueList ; eax now holds address of queue entry

File diff suppressed because it is too large Load Diff

View File

@ -37,7 +37,7 @@ $Revision$
uglobal
StackCounters:
dumped_rx_count: dd 0
dumped_rx_count dd 0
arp_tx_count: dd 0
arp_rx_count: dd 0
ip_rx_count: dd 0
@ -46,9 +46,9 @@ endg
; socket buffers
SOCKETBUFFSIZE equ 4096 ; state + config + buffer.
SOCKETHEADERSIZE equ 76 ; thus 4096 - SOCKETHEADERSIZE bytes data
SOCKETHEADERSIZE equ 76+8+8 ; thus 4096 - SOCKETHEADERSIZE bytes data
NUM_SOCKETS equ 16 ; Number of open sockets supported. Was 20
;NUM_SOCKETS equ 16 ; Number of open sockets supported. Was 20
; IPBUFF status values
BUFF_EMPTY equ 0
@ -94,7 +94,7 @@ ethernet_active equ stack_data + 9
; TODO :: empty memory area
; Address of selected socket
sktAddr equ stack_data + 32
;sktAddr equ stack_data + 32
; Parameter to checksum routine - data ptr
checkAdd1 equ stack_data + 36
; Parameter to checksum routine - 2nd data ptr
@ -110,8 +110,8 @@ checkResult equ stack_data + 48
pseudoHeader equ stack_data + 50
; receive and transmit IP buffer allocation
sockets equ stack_data + 62
Next_free2 equ sockets + (SOCKETBUFFSIZE * NUM_SOCKETS)
;sockets equ stack_data + 62
Next_free2 equ stack_data + 62;Next_free2 equ sockets + (SOCKETBUFFSIZE * NUM_SOCKETS)
; 1560 byte buffer for rx / tx ethernet packets
Ether_buffer equ Next_free2
Next_free3 equ Ether_buffer + 1518
@ -128,9 +128,14 @@ last_1hsTick equ queueList + ( 2 * NUMQUEUEENTRIES )
;resendQ equ 0x770000
resendBuffer equ resendQ + ( 4 * NUMRESENDENTRIES ) ; for TCP
;resendBuffer equ resendQ + ( 4 * NUMRESENDENTRIES ) ; for TCP ; XTODO: validate size
resendBuffer equ resendQ + ( 8 * NUMRESENDENTRIES ) ; for TCP
uglobal
net_sockets rd 2
endg
; simple macro for memory set operation
macro _memset_dw adr,value,amount
{
@ -151,9 +156,6 @@ macro _memset_dw adr,value,amount
include "queue.inc"
include "eth_drv/ethernet.inc"
include "ip.inc"
include "icmp.inc"
include "tcp.inc"
include "udp.inc"
include "socket.inc"
;***************************************************************************
@ -171,7 +173,10 @@ include "socket.inc"
stack_init:
; Init two address spaces with default values
_memset_dw stack_data_start, 0, 0x20000/4
_memset_dw resendQ, 0xFFFFFFFF, NUMRESENDENTRIES
_memset_dw resendQ, 0, NUMRESENDENTRIES * 2
mov [net_sockets], 0
mov [net_sockets + 4], 0
; Queries initialization
call queueInit

File diff suppressed because it is too large Load Diff

View File

@ -71,7 +71,8 @@ end virtual
; Free up (or re-use) IP buffer when finished
;
;***************************************************************************
udp_rx:
proc udp_rx stdcall
push eax
; First validate the header & checksum. Discard buffer if error
@ -80,94 +81,81 @@ udp_rx:
; IP Packet UDP Destination Port = local Port
; IP Packet SA = Remote IP
movzx ebx, word [edx + 22] ; get the local port from
mov ax, [edx + 20 + UDP_PACKET.DestinationPort] ; get the local port from
; the IP packet's UDP header
mov eax, SOCKETBUFFSIZE * NUM_SOCKETS
mov ecx, NUM_SOCKETS
fs1:
sub eax, SOCKETBUFFSIZE
cmp [eax + sockets + 12], bx ; bx will hold the 'wrong' value,
mov ebx, net_sockets
.next_socket:
mov ebx, [ebx + SOCKET.NextPtr]
or ebx, ebx
jz .exit ; No match, so exit
cmp [ebx + SOCKET.LocalPort], ax ; ax will hold the 'wrong' value,
; but the comparision is correct
loopnz fs1 ; Return back if no match
jz fs_done
jne .next_socket ; Return back if no match
; No match, so exit
jmp udprx_001
fs_done:
; For dhcp, we must allow any remote server to respond.
; I will accept the first incoming response to be the one
; I bind to, if the socket is opened with a destination IP address of
; 255.255.255.255
mov ebx, [eax + sockets + 16]
cmp ebx, 0xffffffff
je udprx_002
cmp [ebx + SOCKET.RemoteIP], 0xffffffff
je @f
mov ebx, [edx + 12] ; get the Source address from the IP packet
cmp [eax + sockets + 16], ebx
jne udprx_001 ; Quit if the source IP is not valid
mov eax, [edx + IP_PACKET.SourceAddress] ; get the Source address from the IP packet
cmp [ebx + SOCKET.RemoteIP], ebx
jne .exit ; Quit if the source IP is not valid
udprx_002:
; OK - we have a valid UDP packet for this socket.
@@: ; OK - we have a valid UDP packet for this socket.
; First, update the sockets remote port number with the incoming msg
; - it will have changed
; from the original ( 69 normally ) to allow further connects
movzx ebx, word [edx + 20] ; get the UDP source port
mov ax, [edx + 20 + UDP_PACKET.SourcePort] ; get the UDP source port
; ( was 69, now new )
mov [eax + sockets + 20], bx
mov [ebx + SOCKET.RemotePort], ax
; Now, copy data to socket. We have socket address as [eax + sockets].
; We have IP packet in edx
; get # of bytes in ecx
movzx ecx, byte [edx + 3] ; total length of IP packet. Subtract
mov ch, byte [edx + 2] ; 20 + 8 gives data length
movzx ecx, [edx + IP_PACKET.TotalLength] ; total length of IP packet. Subtract
xchg cl, ch ; 20 + 8 gives data length
sub ecx, 28
mov ebx, eax
add ebx, sockets ; ebx = address of actual socket
mov eax, [ebx + SOCKET.rxDataCount] ; get # of bytes already in buffer
add [ebx + SOCKET.rxDataCount], ecx ; increment the count of bytes in buffer
mov eax, [ebx+ 4] ; get socket owner PID
push eax
mov eax, [ebx + 24] ; get # of bytes already in buffer
add [ebx + 24], ecx ; increment the count of bytes in buffer
; point to the location to store the data
add ebx, eax
add ebx, SOCKETHEADERSIZE
; ebx = location for first byte, ecx has count,
; edx points to data
; ecx has count, edx points to data
add edx, 28 ; edx now points to the data
mov edi, ebx
lea edi, [ebx + eax + SOCKETHEADERSIZE]
mov esi, edx
cld
rep movsb ; copy the data across
; flag an event to the application
pop eax
mov ecx,1
mov esi,TASK_DATA+TASKDATA.pid
mov eax, [ebx + SOCKET.PID] ; get socket owner PID
mov ecx, 1
mov esi, TASK_DATA + TASKDATA.pid
newsearch:
cmp [esi],eax
je foundPID
.next_pid:
cmp [esi], eax
je .found_pid
inc ecx
add esi,0x20
cmp ecx,[TASK_COUNT]
jbe newsearch
add esi, 0x20
cmp ecx, [TASK_COUNT]
jbe .next_pid
foundPID:
shl ecx,8
or dword [ecx+SLOT_BASE+APPDATA.event_mask],dword 10000000b ; stack event
jmp .exit
mov [check_idle_semaphore],200
.found_pid:
shl ecx, 8
or [ecx + SLOT_BASE + APPDATA.event_mask], EVENT_NETWORK ; stack event
udprx_001:
mov [check_idle_semaphore], 200
.exit:
pop eax
call freeBuff ; Discard the packet
ret
endp

View File

@ -880,6 +880,14 @@ vesa12_putimage:
add edi,[BytesPerScanLine]
add esi,[esp+32]
cmp ebp,putimage_get1bpp
jz .correct
cmp ebp,putimage_get4bpp
jnz @f
.correct:
mov eax,[esp+20]
mov byte[eax],80h
@@:
dec ebx
jnz newpi12
@ -945,6 +953,14 @@ vesa12_putimage:
pop edi
add edi,[BytesPerScanLine]
cmp ebp,putimage_get1bpp
jz .correct
cmp ebp,putimage_get4bpp
jnz @f
.correct:
mov eax,[esp+20]
mov byte[eax],80h
@@:
dec ebx
jnz newpi3212

View File

@ -163,7 +163,8 @@ vesa20_putimage:
mov [putimg.real_sy], ebx
; line increment
mov eax, [putimg.image_sx]
sub eax, [putimg.real_sx]
mov ecx, [putimg.real_sx]
sub eax, ecx
;; imul eax, [putimg.source_bpp]
; lea eax, [eax + eax * 2]
call esi
@ -176,7 +177,6 @@ vesa20_putimage:
mov [putimg.winmap_newline], eax
; screen new line increment
mov eax, [BytesPerScanLine]
mov ecx, [putimg.real_sx]
movzx ebx, byte [ScreenBPP]
shr ebx, 3
imul ecx, ebx
@ -232,6 +232,14 @@ align 4
add edx, [putimg.screen_newline] ;[BytesPerScanLine]
add ebp, [putimg.winmap_newline] ;[Screen_Max_X]
; inc ebp
cmp [putimg.ebp], putimage_get1bpp
jz .correct
cmp [putimg.ebp], putimage_get4bpp
jnz @f
.correct:
mov eax, [putimg.edi]
mov byte [eax], 80h
@@:
dec edi
jnz .new_line
.finish:
@ -265,6 +273,14 @@ align 4
add edx, [putimg.screen_newline] ;[BytesPerScanLine]
add ebp, [putimg.winmap_newline] ;[Screen_Max_X]
; inc ebp
cmp [putimg.ebp], putimage_get1bpp
jz .correct
cmp [putimg.ebp], putimage_get4bpp
jnz @f
.correct:
mov eax, [putimg.edi]
mov byte [eax], 80h
@@:
dec edi
jnz .new_line
.finish: