Kernel Clipboard. f.54.
git-svn-id: svn://kolibrios.org@4199 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
2671910c07
commit
9c4fa92828
|
@ -0,0 +1,148 @@
|
|||
;------------------------------------------------------------------------------
|
||||
align 4
|
||||
sys_clipboard:
|
||||
xor eax, eax
|
||||
dec eax
|
||||
; check availability of main list
|
||||
cmp [clipboard_main_list], eax
|
||||
je .exit_1 ; main list area not found
|
||||
|
||||
test ebx, ebx ; 0 - Get the number of slots in the clipboard
|
||||
jnz .1
|
||||
; get the number of slots
|
||||
mov eax, [clipboard_slots]
|
||||
jmp .exit_1
|
||||
;------------------------------------------------------------------------------
|
||||
align 4
|
||||
.1:
|
||||
dec ebx ; 1 - Read the data from the clipboard
|
||||
jnz .2
|
||||
; verify the existence of slot
|
||||
cmp ecx, [clipboard_slots]
|
||||
jae .exit_2
|
||||
; get a pointer to the data of slot
|
||||
shl ecx, 2
|
||||
add ecx, [clipboard_main_list]
|
||||
mov esi, [ecx]
|
||||
mov ecx, [esi]
|
||||
; allocate memory for application for copy the data of slots
|
||||
push ecx
|
||||
stdcall user_alloc, ecx
|
||||
pop ecx
|
||||
; copying data of slots
|
||||
mov edi, eax
|
||||
cld
|
||||
rep movsb
|
||||
jmp .exit_1
|
||||
;------------------------------------------------------------------------------
|
||||
align 4
|
||||
.2:
|
||||
dec ebx ; 2 - Write the data to the clipboard
|
||||
jnz .3
|
||||
; check the lock
|
||||
mov ebx, clipboard_write_lock
|
||||
xor eax, eax
|
||||
cmp [ebx], eax
|
||||
jne .exit_2
|
||||
; lock last slot
|
||||
inc eax
|
||||
mov [ebx], eax
|
||||
; check the overflow pointer of slots
|
||||
cmp [clipboard_slots], 1024
|
||||
jae .exit_3
|
||||
; get memory for new slot
|
||||
push ebx ecx edx
|
||||
stdcall kernel_alloc, ecx
|
||||
pop edx ecx ebx
|
||||
test eax, eax
|
||||
jz .exit_3
|
||||
; create a new slot
|
||||
mov edi, eax
|
||||
mov eax, [clipboard_slots]
|
||||
shl eax, 2
|
||||
add eax, [clipboard_main_list]
|
||||
mov [eax], edi
|
||||
; copy the data into the slot
|
||||
mov esi, edx
|
||||
mov eax, ecx
|
||||
cld
|
||||
stosd ; store size of slot
|
||||
sub ecx, 4
|
||||
add esi, 4
|
||||
rep movsb ; store slot data
|
||||
; increase the counter of slots
|
||||
inc [clipboard_slots]
|
||||
; unlock last slot
|
||||
xor eax, eax
|
||||
mov [ebx], eax
|
||||
jmp .exit_1
|
||||
;------------------------------------------------------------------------------
|
||||
align 4
|
||||
.3:
|
||||
dec ebx ; 3 - Delete the last slot in the clipboard
|
||||
jnz .4
|
||||
; check the availability of slots
|
||||
mov eax, [clipboard_slots]
|
||||
test eax, eax
|
||||
jz .exit_2
|
||||
; check the lock
|
||||
mov ebx, clipboard_write_lock
|
||||
xor eax, eax
|
||||
cmp [ebx], eax
|
||||
jne .exit_2
|
||||
; lock last slot
|
||||
inc eax
|
||||
mov [ebx], eax
|
||||
; decrease the counter of slots
|
||||
mov eax, clipboard_slots
|
||||
dec dword [eax]
|
||||
; free of kernel memory allocated for the slot
|
||||
mov eax, [eax]
|
||||
shl eax, 2
|
||||
add eax, [clipboard_main_list]
|
||||
mov eax, [eax]
|
||||
push ebx
|
||||
stdcall kernel_free, eax
|
||||
pop ebx
|
||||
; unlock last slot
|
||||
xor eax, eax
|
||||
mov [ebx], eax
|
||||
jmp .exit_1
|
||||
;------------------------------------------------------------------------------
|
||||
align 4
|
||||
.4:
|
||||
dec ebx ; 4 - Emergency discharge of clipboard
|
||||
jnz .exit
|
||||
; check the lock
|
||||
mov ebx, clipboard_write_lock
|
||||
xor eax, eax
|
||||
cmp [ebx], eax
|
||||
je .exit_2
|
||||
|
||||
; there should be a procedure for checking the integrity of the slots
|
||||
; and I will do so in the future
|
||||
|
||||
; unlock last slot
|
||||
mov [ebx], eax
|
||||
jmp .exit
|
||||
;------------------------------------------------------------------------------
|
||||
align 4
|
||||
.exit_3:
|
||||
; unlock last slot
|
||||
xor eax, eax
|
||||
mov [ebx], eax
|
||||
.exit_2:
|
||||
xor eax, eax
|
||||
inc eax ; error
|
||||
.exit_1:
|
||||
mov [esp + 32], eax
|
||||
.exit:
|
||||
ret
|
||||
;------------------------------------------------------------------------------
|
||||
uglobal
|
||||
align 4
|
||||
clipboard_slots dd ?
|
||||
clipboard_main_list dd ?
|
||||
clipboard_write_lock dd ?
|
||||
endg
|
||||
;------------------------------------------------------------------------------
|
|
@ -184,7 +184,7 @@ iglobal
|
|||
dd syscall_threads ; 51-Threads
|
||||
dd undefined_syscall ; 52- deprecated Stack driver status
|
||||
dd undefined_syscall ; 53- deprecated Socket interface
|
||||
dd undefined_syscall ; 54-reserved
|
||||
dd sys_clipboard ; 54-Custom clipboard
|
||||
dd sound_interface ; 55-Sound interface
|
||||
dd undefined_syscall ; 56-reserved
|
||||
dd sys_pcibios ; 57-PCI BIOS32
|
||||
|
|
|
@ -2427,6 +2427,70 @@ dword-значение цвета 0x00RRGGBB
|
|||
* eax = -1 - ошибка (в системе слишком много потоков)
|
||||
* иначе eax = TID - идентификатор потока
|
||||
|
||||
======================================================================
|
||||
====================== Функция 54, подфункция 0 ======================
|
||||
============== Узнать количество слотов в буфере обмена. =============
|
||||
======================================================================
|
||||
Параметры:
|
||||
* eax = 54 - номер функции
|
||||
* ebx = 0 - номер подфункции
|
||||
Возвращаемое значение:
|
||||
* eax = количество слотов в буфере
|
||||
* eax = -1 - отсутствует область главного списка
|
||||
|
||||
======================================================================
|
||||
====================== Функция 54, подфункция 1 ======================
|
||||
================== Считать данные из буфера обмена. ==================
|
||||
======================================================================
|
||||
Параметры:
|
||||
* eax = 54 - номер функции
|
||||
* ebx = 1 - номер подфункции
|
||||
* eсx = номер слота
|
||||
Возвращаемое значение:
|
||||
* eax = если успешно - указатель на область памяти с данными
|
||||
* eax = 1 - ошибка
|
||||
* eax = -1 - отсутствует область главного списка
|
||||
|
||||
======================================================================
|
||||
====================== Функция 54, подфункция 2 ======================
|
||||
================== Записать данные в буфер обмена. ===================
|
||||
======================================================================
|
||||
Параметры:
|
||||
* eax = 54 - номер функции
|
||||
* ebx = 2 - номер подфункции
|
||||
* eсx = количество копируемых байт
|
||||
* edx = указатель на буфер под копируемые данные
|
||||
Возвращаемое значение:
|
||||
* eax = 0 - успешно
|
||||
* eax = 1 - ошибка
|
||||
* eax = -1 - отсутствует область главного списка
|
||||
|
||||
======================================================================
|
||||
====================== Функция 54, подфункция 3 ======================
|
||||
========= Удалить последний слот с данными в буфере обмена ===========
|
||||
======================================================================
|
||||
Параметры:
|
||||
* eax = 54 - номер функции
|
||||
* ebx = 3 - номер подфункции
|
||||
Возвращаемое значение:
|
||||
* eax = 0 - успешно
|
||||
* eax = 1 - ошибка
|
||||
* eax = -1 - отсутствует область главного списка
|
||||
|
||||
======================================================================
|
||||
====================== Функция 54, подфункция 4 ======================
|
||||
=================== Аварийный сброс блокировки буфера ================
|
||||
======================================================================
|
||||
Параметры:
|
||||
* eax = 54 - номер функции
|
||||
* ebx = 4 - номер подфункции
|
||||
Возвращаемое значение:
|
||||
* eax = 0 - успешно
|
||||
* eax = -1 - отсутствует область главного списка или нет блокировки
|
||||
Замечания:
|
||||
* Используется в исключительных случаях, когда зависшее или убитое
|
||||
приложение заблокировало работу с буфером обмена.
|
||||
|
||||
======================================================================
|
||||
====================== Функция 55, подфункция 55 =====================
|
||||
========== Начать проигрывать данные на встроенном спикере. ==========
|
||||
|
|
|
@ -2410,6 +2410,70 @@ Returned value:
|
|||
* otherwise eax = TID - thread identifier
|
||||
</UL>
|
||||
|
||||
======================================================================
|
||||
==================== Function 54, subfunction 0 ======================
|
||||
============== Get the number of slots in the clipboard. =============
|
||||
======================================================================
|
||||
Parameters:
|
||||
* eax = 54 - function number
|
||||
* ebx = 0 - subfunction number
|
||||
Returned value:
|
||||
* eax = slots in the clipboard
|
||||
* eax = -1 - main list area not found
|
||||
|
||||
======================================================================
|
||||
==================== Function 54, subfunction 1 ======================
|
||||
================= Read the data from the clipboard. ==================
|
||||
======================================================================
|
||||
Parameters:
|
||||
* eax = 54 - function number
|
||||
* ebx = 1 - subfunction number
|
||||
* eсx = slot number
|
||||
Returned value:
|
||||
* eax = if successful - pointer to a memory with data
|
||||
* eax = 1 - error
|
||||
* eax = -1 - main list area not found
|
||||
|
||||
======================================================================
|
||||
==================== Function 54, subfunction 2 ======================
|
||||
================= Write the data to the clipboard. ===================
|
||||
======================================================================
|
||||
Parameters:
|
||||
* eax = 54 - function number
|
||||
* ebx = 2 - subfunction number
|
||||
* eсx = the number of bytes to be copied
|
||||
* edx = a pointer to a buffer for data to be copied
|
||||
Returned value:
|
||||
* eax = 0 - success
|
||||
* eax = 1 - error
|
||||
* eax = -1 - main list area not found
|
||||
|
||||
======================================================================
|
||||
===================== Function 54, subfunction 3 =====================
|
||||
================ Delete the last slot in the clipboard ===============
|
||||
======================================================================
|
||||
Parameters:
|
||||
* eax = 54 - function number
|
||||
* ebx = 3 - subfunction number
|
||||
Returned value:
|
||||
* eax = 0 - success
|
||||
* eax = 1 - error
|
||||
* eax = -1 - main list area not found
|
||||
|
||||
======================================================================
|
||||
===================== Function 54, subfunction 4 =====================
|
||||
===================== Alarm reset the lock buffer ====================
|
||||
======================================================================
|
||||
Parameters:
|
||||
* eax = 54 - function number
|
||||
* ebx = 4 - subfunction number
|
||||
Returned value:
|
||||
* eax = 0 - success
|
||||
* eax = -1 - main list area not found or no blocking
|
||||
Remarks:
|
||||
* Used in exceptional cases, where no responsible or killed
|
||||
application blocked the clipboard operations.
|
||||
|
||||
======================================================================
|
||||
Function 55, subfunction 55 - begin to play data on built-in speaker.
|
||||
======================================================================
|
||||
|
|
|
@ -698,6 +698,19 @@ no_mode_0x12:
|
|||
mov [mem_BACKGROUND], 4
|
||||
mov [img_background], static_background_data
|
||||
|
||||
; set clipboard
|
||||
|
||||
xor eax, eax
|
||||
mov [clipboard_slots], eax
|
||||
mov [clipboard_write_lock], eax
|
||||
stdcall kernel_alloc, 4096
|
||||
test eax, eax
|
||||
jnz @f
|
||||
|
||||
dec eax
|
||||
@@:
|
||||
mov [clipboard_main_list], eax
|
||||
|
||||
; SET UP OS TASK
|
||||
|
||||
mov esi, boot_setostask
|
||||
|
|
|
@ -171,6 +171,7 @@ include "core/v86.inc" ; virtual-8086 manager
|
|||
include "core/irq.inc" ; irq handling functions
|
||||
include "core/apic.inc" ; Interrupt Controller functions
|
||||
include "core/timers.inc"
|
||||
include "core/clipboard.inc" ; custom clipboard
|
||||
|
||||
; GUI stuff
|
||||
include "gui/window.inc"
|
||||
|
|
Loading…
Reference in New Issue