Compare commits

..
Author SHA1 Message Date
Leency 36854f1382 kernel/net: allocate socket rings from non-contiguous pages
Check kernel codestyle / Check kernel codestyle (pull_request) Successful in 34s
Test PR / Build (en_US) (pull_request) Successful in 2m38s
Test PR / Build (es_ES) (pull_request) Successful in 2m30s
Test PR / Build (ru_RU) (pull_request) Successful in 2m26s
2026-09-30 13:49:15 +03:00
Leency f990a48b98 kernel/net: check that STREAM_SOCKET fits in SOCKET_STRUCT_SIZE 2026-09-30 13:49:14 +03:00
Leency fb2906bc1d kernel: release address space when kernel_alloc fails 2026-09-30 13:49:13 +03:00
Leency 9c58dc1f04 kernel: flush the mirror half in create_ring_buffer 2026-09-30 13:49:11 +03:00
13 changed files with 128 additions and 79 deletions

No files matched your search

-1
View File
@@ -166,7 +166,6 @@ extra_files = {
{"kolibrios/demos/rpento.lif", "common/demos/rpento.lif"},
{"kolibrios/develop/fpc/", "common/develop/fpc/*"},
{"kolibrios/develop/fpc/examples/", "../programs/develop/fp/examples/src/*"},
{"kolibrios/develop/fasm/fasm.txt", SRC_PROGS .. "/develop/fasm/1.73/fasm.txt"},
{"kolibrios/develop/oberon07/compiler.kex", SRC_PROGS .. "/develop/oberon07/Compiler.kex"},
{"kolibrios/develop/oberon07/LICENSE", SRC_PROGS .. "/develop/oberon07/LICENSE"},
{"kolibrios/develop/oberon07/doc/CC.txt", SRC_PROGS .. "/develop/oberon07/doc/CC.txt"},
+5 -5
View File
@@ -20,13 +20,13 @@
<a href="hardware_support.htm">Поддержка оборудования</a>
<strong>Разработка</strong>
<a href="/sys/docpack|d">Справочник по системным функциям Колибри</a>
<a href="/sys/docpack|c">Использование отладчика</a>
<a href="/kolibrios/develop/fasm/fasm.txt">Руководство FASM</a>
<a href="/sys/docpack|f">Справочник по системным функциям Колибри</a>
<a href="/sys/docpack|e">Использование отладчика</a>
<a href="/sys/docpack|d">Руководство FASM</a>
<strong>Использование библиотек</strong>
<a href="/sys/docpack|g">Ini</a>
<a href="/sys/docpack|h">Диалог открытия файла OpenDial</a>
<a href="/sys/docpack|i">Ini</a>
<a href="/sys/docpack|j">Диалог открытия файла OpenDial</a>
<strong>Смотрите также</strong>
Вики проекта <a href="http://wiki.kolibrios.org/">wiki.kolibrios.org</a>
+8 -1
View File
@@ -463,7 +463,7 @@ proc kernel_alloc stdcall, size:dword
and eax, -PAGE_SIZE;
mov [size], eax
and eax, eax
jz .err
jz .err0
mov ebx, eax
shr ebx, 12
mov [pages_count], ebx
@@ -509,6 +509,13 @@ proc kernel_alloc stdcall, size:dword
pop ebx
ret
.err:
mov eax, [lin_addr]
test eax, eax
jz .err0
mov ecx, [pages_count]
call release_pages
stdcall free_kernel_space, [lin_addr]
.err0:
xor eax, eax
pop edi
pop ebx
+59 -1
View File
@@ -1397,7 +1397,9 @@ proc create_ring_buffer stdcall, size:dword, flags:dword
mov [page_tabs + edi], eax
mov [page_tabs + edi + edx], eax
invlpg [ebx]
invlpg [ebx+0x10000]
add ebx, [size]
invlpg [ebx] ; the mirror half
sub ebx, [size]
add eax, 0x1000
add ebx, 0x1000
add edi, 4
@@ -1416,6 +1418,62 @@ proc create_ring_buffer stdcall, size:dword, flags:dword
ret
endp
; Same as create_ring_buffer, but from non-contiguous pages.
; Not for DMA. Free with kernel_free.
align 4
proc create_ring_buffer_sparse stdcall, size:dword, flags:dword
locals
buf_ptr dd ?
endl
mov eax, [size]
test eax, eax
jz .fail
add eax, eax
stdcall alloc_kernel_space, eax
test eax, eax
jz .fail
mov [buf_ptr], eax
push ebx esi edi
mov ebx, eax ; page being mapped
mov esi, [size] ; distance to its mirror
mov edi, esi
shr edi, 12 ; pages left
.page:
call alloc_page
test eax, eax
jz .mm_fail
or eax, [flags]
mov edx, ebx
shr edx, 12
mov [page_tabs + edx*4], eax
invlpg [ebx]
lea edx, [ebx + esi]
shr edx, 12
mov [page_tabs + edx*4], eax
invlpg [ebx + esi]
add ebx, PAGE_SIZE
dec edi
jnz .page
mov eax, [buf_ptr]
pop edi esi ebx
ret
.mm_fail:
mov eax, [buf_ptr]
mov ecx, [size]
shr ecx, 11 ; both halves, in pages
call release_pages
stdcall free_kernel_space, [buf_ptr]
pop edi esi ebx
xor eax, eax
.fail:
ret
endp
align 4
proc print_mem
+5 -1
View File
@@ -198,6 +198,10 @@ ends
SOCKET_STRUCT_SIZE = 4096 ; in bytes
if sizeof.STREAM_SOCKET > SOCKET_STRUCT_SIZE
err "STREAM_SOCKET does not fit in SOCKET_STRUCT_SIZE"
end if
SOCKET_QUEUE_SIZE = 10 ; maximum number of incoming packets queued for 1 socket
; the incoming packet queue for sockets is placed in the socket struct itself, at this location from start
SOCKET_QUEUE_LOCATION = (SOCKET_STRUCT_SIZE - SOCKET_QUEUE_SIZE*sizeof.socket_queue_entry - sizeof.queue)
@@ -1647,7 +1651,7 @@ socket_ring_create:
mov esi, eax
push edx
stdcall create_ring_buffer, SOCKET_BUFFER_SIZE, PG_SWR
stdcall create_ring_buffer_sparse, SOCKET_BUFFER_SIZE, PG_SWR
pop edx
test eax, eax
jz .fail
+2 -7
View File
@@ -31,7 +31,6 @@ macro debug_print_dec arg
dpd fix debug_print_dec
;---------------------------------
if used debug_outdec
debug_outdec: ;(eax - num, edi-str)
push 10 ;2
pop ecx ;1
@@ -60,9 +59,7 @@ debug_outchar: ; al - char
popad
popf
ret
end if
if used debug_outstr
debug_outstr:
mov eax,63
mov ebx,1
@@ -75,7 +72,7 @@ debug_outstr:
jmp @b
@@:
ret
end if
macro newline
{
@@ -115,7 +112,6 @@ macro debug_print_hex arg
}
dph fix debug_print_hex
if used debug_outhex
debug_outhex:
; eax - number
mov edx, 8
@@ -134,5 +130,4 @@ debug_outhex:
ret
__hexdigits:
db '0123456789ABCDEF'
end if
db '0123456789ABCDEF'
+3 -12
View File
@@ -104,12 +104,8 @@ START:
load_libraries l_libs_start,end_l_libs
cmp [lib1.status_lib],0
jnz close
cmp [lib2.status_lib],0
jnz close
cmp [lib4.status_lib],0
jnz close
cmp eax,-1
jz close
mcall SF_SET_EVENTS_MASK,0x80000067 ; 1100111b
;---------------------------------------------------------
@@ -226,14 +222,9 @@ include 'menu.inc'
;-----------------------------------------------------------
;------------variables and data of program------------------
;-----------------------------------------------------------
name_of_program db 'ANIMAGE graphics editor v1.54',0
mouse_pos_x db 'X='
mouse_pos_y db 'Y='
new_text1 db 'Picture size X'
new_text2 db 'Picture size Y'
ok_text db 'OK'
include 'lib_data.inc'
include 'panel_data.inc'
include 'brushes.inc'
include 'spray.inc'
include 'width_lines.inc'
@@ -3,23 +3,8 @@
;---------------------------------------------
align 4
mouse:
cmp [lib3.status_lib],0 ; test load library
jnz .m_end
cld
stdcall [kmainmenu_dispatch_cursorevent], [main_menu]
mov eax,[main_menu]
cmp dword[eax+16],-1
je @f
mov [m_lost],1
jmp still
@@:
cmp [m_lost],0
je .m_end
dec [m_lost]
jmp still
.m_end:
or ecx,-1
mcall SF_THREAD_INFO,procinfo
+24 -19
View File
@@ -1,13 +1,15 @@
align 4
square_width_put:
macro square_width_put
{
local .no_put_to_screen
local .next_color_put
local .vertical_width_put
local .horizontal_width_put
mov ebx,[ReserveArray]
mov eax,[ebx]
test eax,eax
jz .no_put_to_screen
mov ecx,[ebx]
cmp ecx,[Picture_SizeX]
jg .no_put_to_screen ;if ecx > screen size return
add ebx,4
xor ebp,ebp
@@ -46,10 +48,13 @@ square_width_put:
jnz .next_color_put
.no_put_to_screen:
ret
}
align 4
square_width_save:
macro square_width_save
{
local .next_color_save
local .vertical_width_save
local .horizontal_width_save
mov ebx,[ReserveArray]
mov [ebx],eax
mov ecx,eax
@@ -88,7 +93,7 @@ square_width_save:
add ebx,4
dec ecx
jnz .next_color_save
ret
}
macro draw_calc_pixels brush
{
@@ -675,7 +680,7 @@ TakeButtonInstruments:
no_new_line_xy:
;put saved pixels
call square_width_put
square_width_put
;calculate line
mov ebx,[ReserveArray]
@@ -707,7 +712,7 @@ TakeButtonInstruments:
call calculate_line
;save color pixels in ReserveArray
call square_width_save
square_width_save
;draw calculated pixels on work arrea
draw_calc_pixels width_pixels
@@ -741,7 +746,7 @@ TakeButtonInstruments:
no_new_rectangle_xy:
;put saved pixels
call square_width_put
square_width_put
;calculate line
mov ebx,[ReserveArray]
@@ -773,7 +778,7 @@ TakeButtonInstruments:
call calculate_rectangle
;save color pixels in ReserveArray
call square_width_save
square_width_save
;draw calculated pixels on work arrea
draw_calc_pixels width_pixels_rectangle
@@ -807,7 +812,7 @@ TakeButtonInstruments:
no_new_circle_xy:
;put saved pixels
call square_width_put
square_width_put
mov esi,[ScreenX]
mov edi,[ScreenY]
@@ -926,7 +931,7 @@ TakeButtonInstruments:
call calculate_circle
;save color pixels in ReserveArray
call square_width_save
square_width_save
;draw calculated pixels on work arrea
draw_calc_pixels width_pixels
@@ -1306,7 +1311,7 @@ end if
no_new_konture_xy:
;put saved pixels
call square_width_put
square_width_put
;calculate line
mov ebx,[ReserveArray]
@@ -1338,7 +1343,7 @@ end if
call calculate_line
;save color pixels in ReserveArray
call square_width_save
square_width_save
;draw calculated pixels on work arrea
draw_calc_pixels width_pixels
@@ -1379,7 +1384,7 @@ end if
no_new_ellips_xy:
;put saved pixels
call square_width_put
square_width_put
mov esi,[ScreenX]
@@ -1490,7 +1495,7 @@ end if
call calculate_ellips
;save color pixels in ReserveArray
call square_width_save
square_width_save
;draw calculated pixels on work arrea
draw_calc_pixels width_pixels
-8
View File
@@ -15,8 +15,6 @@ no_set:
}
init_main_menu:
cmp [lib3.status_lib],0 ; test load library
jnz @f
stdcall [kmenu_init], syscolors
stdcall [ksubmenu_new]
@@ -112,14 +110,10 @@ init_main_menu:
; add 'Reflection' menu to main
stdcall [kmenuitem_new], KMENUITEM_SUBMENU, sz_main_menu_Filters, [main_menu_filters]
stdcall [ksubmenu_add], [main_menu], eax
@@:
ret
put_main_menu:
cmp [lib3.status_lib],0 ; test load library
jnz @f
stdcall [kmainmenu_draw], [main_menu]
@@:
ret
button_handler_main_menu:
@@ -151,13 +145,11 @@ button_handler_main_menu:
.end_handler:
ret
align 4
main_menu dd 0
main_menu_file dd 0
main_menu_edit dd 0
main_menu_instr dd 0
main_menu_filters dd 0
m_lost db 0
sz_main_menu_File db 'File', 0
sz_main_menu_File_New db 'New', 0
+9
View File
@@ -0,0 +1,9 @@
;**********************************************************
;------------------TEXT DATA-------------------------------
;**********************************************************
name_of_program db 'ANIMAGE graphics editor v1.53',0
mouse_pos_x db 'X='
mouse_pos_y db 'Y='
new_text1 db 'PICTURE SIZE X'
new_text2 db 'PICTURE SIZE Y'
ok_text db 'OK'
+3
View File
@@ -15,6 +15,9 @@ then tup.append_table(deps,
else tup.append_table(deps,
tup.rule("../../../kernel/trunk/docs/sysfuncs.txt", cp_cmd, "SysFuncs.txt"))
end
tup.append_table(deps,
tup.rule("../../develop/fasm/1.73/fasm.txt", cp_cmd, "Fasm.txt")
)
tup.append_table(deps,
tup.rule("../../../kernel/trunk/docs/stack.txt", cp_cmd, "Stack.txt")
)
+10 -9
View File
@@ -9,7 +9,7 @@
;---------------------------------------------------------------------
FILE_COUNT=0
DEF_FILE equ 'f'
DEF_FILE equ 'g'
macro embed_docdir_file fn
{
@@ -197,17 +197,18 @@ embedded:
embed_docdir_file 'Copying.txt' ;a
embed_docdir_file 'Hot_Keys.txt' ;b
embed_docdir_file 'Mtdbg.txt' ;c
embed_local_file 'Fasm.txt' ;c
embed_docdir_file 'Mtdbg.txt' ;d
if lang eq ru_RU
embed_local_file 'SysFuncr.txt' ;d
embed_local_file 'SysFuncr.txt' ;e
else ; Default to en_US
embed_local_file 'SysFuncs.txt' ;d
embed_local_file 'SysFuncs.txt' ;e
end if
embed_local_file 'Stack.txt' ;e
embed_docdir_file 'KFAR_Keys.txt' ;f
embed_docdir_file 'INI.txt' ;g
embed_docdir_file 'OpenDial.txt' ;h
embed_docdir_file 'Credits.txt' ;i
embed_local_file 'Stack.txt' ;f
embed_docdir_file 'KFAR_Keys.txt' ;g
embed_docdir_file 'INI.txt' ;h
embed_docdir_file 'OpenDial.txt' ;i
embed_docdir_file 'Credits.txt' ;j
; -- End of embedding area -------
dd 0