forked from KolibriOS/kolibrios
1) Added kobra_st.s which is needed to compile Kobra
2) Added basic SDK to work with Kobra git-svn-id: svn://kolibrios.org@1261 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
5c55e63fc6
commit
12e34168d4
32
programs/develop/sdk/trunk/kobra/ipc.inc
Normal file
32
programs/develop/sdk/trunk/kobra/ipc.inc
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;; Copyright (C) Vasiliy Kosenko (vkos), 2009 ;;
|
||||||
|
;; This program is free software: you can redistribute it and/or modify it under the terms of ;;
|
||||||
|
;; the GNU General Public License as published by the Free Software Foundation, either version 3 ;;
|
||||||
|
;; of the License, or (at your option) any later version. ;;
|
||||||
|
;; ;;
|
||||||
|
;; This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; ;;
|
||||||
|
;; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See ;;
|
||||||
|
;; the GNU General Public License for more details. ;;
|
||||||
|
;; ;;
|
||||||
|
;; You should have received a copy of the GNU General Public License along with this program. ;;
|
||||||
|
;; If not, see <http://www.gnu.org/licenses/>. ;;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;; This is set of functions to work with IPC in KolibriOS ;;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
IPC_init:
|
||||||
|
push eax
|
||||||
|
mov eax, dword [IPC_area]
|
||||||
|
mov dword [eax], 1
|
||||||
|
mov dword [eax+4], 8
|
||||||
|
|
||||||
|
stdcall event_add_mask, 0x40
|
||||||
|
|
||||||
|
pop eax
|
||||||
|
|
||||||
|
ret
|
||||||
|
|
||||||
|
IPC_area:
|
||||||
|
dd 0
|
96
programs/develop/sdk/trunk/kobra/kobra.inc
Normal file
96
programs/develop/sdk/trunk/kobra/kobra.inc
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;; Copyright (C) Vasiliy Kosenko (vkos), 2009 ;;
|
||||||
|
;; Kobra is free software: you can redistribute it and/or modify it under the terms of the GNU ;;
|
||||||
|
;; General Public License as published by the Free Software Foundation, either version 3 ;;
|
||||||
|
;; of the License, or (at your option) any later version. ;;
|
||||||
|
;; ;;
|
||||||
|
;; Kobra is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;;
|
||||||
|
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
|
||||||
|
;; General Public License for more details. ;;
|
||||||
|
;; ;;
|
||||||
|
;; You should have received a copy of the GNU General Public License along with Kobra. ;;
|
||||||
|
;; If not, see <http://www.gnu.org/licenses/>. ;;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;; This is set of functions to work with Kobra daemon ;;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
define KOBRA_MESSAGE_MAX_LEN 0x100
|
||||||
|
|
||||||
|
define KOBRA_CMD_REGISTER 'R'
|
||||||
|
define KOBRA_CMD_JOIN 'J'
|
||||||
|
define KOBRA_CMD_UNJOIN 'U'
|
||||||
|
define KOBRA_CMD_SEND 'S'
|
||||||
|
|
||||||
|
define KOBRA_MESSAGE_LAUNCH_STATE 1
|
||||||
|
|
||||||
|
kobra_register:
|
||||||
|
mov eax, kobra_message_area
|
||||||
|
mov byte [eax], KOBRA_CMD_REGISTER
|
||||||
|
|
||||||
|
stdcall thread_find_by_name, kobra_thread_name
|
||||||
|
|
||||||
|
test eax, eax
|
||||||
|
je .error
|
||||||
|
|
||||||
|
mov dword [kobra_tid], eax ;; Save tid
|
||||||
|
|
||||||
|
mov ecx, eax
|
||||||
|
|
||||||
|
mcall 60, 2, , kobra_message_area, 1
|
||||||
|
|
||||||
|
test eax, eax
|
||||||
|
je .return
|
||||||
|
|
||||||
|
.error:
|
||||||
|
inc eax
|
||||||
|
|
||||||
|
.return:
|
||||||
|
ret
|
||||||
|
|
||||||
|
;; void kobra_send_message(char *group, void *message, int length);
|
||||||
|
kobra_send_message:
|
||||||
|
push ebp
|
||||||
|
mov ebp, esp
|
||||||
|
|
||||||
|
cld
|
||||||
|
|
||||||
|
mov edi, kobra_message_area
|
||||||
|
mov al, KOBRA_CMD_SEND
|
||||||
|
stosb
|
||||||
|
|
||||||
|
mov esi, dword [ebp+8]
|
||||||
|
|
||||||
|
.copy_group_cycle:
|
||||||
|
mov al, byte [esi]
|
||||||
|
test al, al
|
||||||
|
jz .copy_group_end
|
||||||
|
movsb
|
||||||
|
jmp .copy_group_cycle
|
||||||
|
|
||||||
|
.copy_group_end:
|
||||||
|
|
||||||
|
; xor al, al
|
||||||
|
stosb
|
||||||
|
|
||||||
|
mov esi, dword [ebp+12]
|
||||||
|
mov ecx, dword [ebp+16]
|
||||||
|
rep movsb
|
||||||
|
|
||||||
|
lea eax, [edi-kobra_message_area]
|
||||||
|
|
||||||
|
mcall 60, 2, dword [kobra_tid], kobra_message_area, eax
|
||||||
|
|
||||||
|
leave
|
||||||
|
|
||||||
|
ret 12
|
||||||
|
|
||||||
|
kobra_tid:
|
||||||
|
dd 0
|
||||||
|
|
||||||
|
kobra_message_area:
|
||||||
|
rb KOBRA_MESSAGE_MAX_LEN
|
||||||
|
|
||||||
|
kobra_thread_name:
|
||||||
|
db "kobra", 0, 0, 0, 0, 0, 0
|
81
programs/develop/sdk/trunk/kobra/thread.inc
Normal file
81
programs/develop/sdk/trunk/kobra/thread.inc
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;; Copyright (C) Vasiliy Kosenko (vkos), 2009 ;;
|
||||||
|
;; This program is free software: you can redistribute it and/or modify it under the terms of ;;
|
||||||
|
;; the GNU General Public License as published by the Free Software Foundation, either version 3 ;;
|
||||||
|
;; of the License, or (at your option) any later version. ;;
|
||||||
|
;; ;;
|
||||||
|
;; This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; ;;
|
||||||
|
;; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See ;;
|
||||||
|
;; the GNU General Public License for more details. ;;
|
||||||
|
;; ;;
|
||||||
|
;; You should have received a copy of the GNU General Public License along with this program. ;;
|
||||||
|
;; If not, see <http://www.gnu.org/licenses/>. ;;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
thread_find_by_name:
|
||||||
|
cld
|
||||||
|
|
||||||
|
push ebp
|
||||||
|
mov ebp, esp
|
||||||
|
|
||||||
|
push ebx ecx
|
||||||
|
|
||||||
|
push 1 ;; initial slot
|
||||||
|
|
||||||
|
mov ebx, dword [thread_find_buff]
|
||||||
|
|
||||||
|
push 0
|
||||||
|
|
||||||
|
.cycle:
|
||||||
|
mcall 9 ;; Get thread info
|
||||||
|
mov dword [esp], eax ;; number of slots
|
||||||
|
|
||||||
|
cmp word [ebx+0x32], 9
|
||||||
|
je .next
|
||||||
|
|
||||||
|
.cmpstr:
|
||||||
|
mov ecx, 11
|
||||||
|
|
||||||
|
mov esi, dword [thread_find_buff]
|
||||||
|
add esi, 0xA ;; ESI = address of thread name in list
|
||||||
|
|
||||||
|
mov edi, dword [ebp+8] ;; EDI = address of thread name to find
|
||||||
|
|
||||||
|
repe cmpsb
|
||||||
|
je .found
|
||||||
|
|
||||||
|
.next:
|
||||||
|
mov ecx, dword [esp+4]
|
||||||
|
inc ecx
|
||||||
|
cmp ecx, dword [esp]
|
||||||
|
jg .not_found
|
||||||
|
mov dword [esp+4], ecx
|
||||||
|
jmp .cycle
|
||||||
|
|
||||||
|
.found:
|
||||||
|
mov eax, dword [ebx+30] ;; return TID
|
||||||
|
|
||||||
|
jmp .exit
|
||||||
|
|
||||||
|
.not_found:
|
||||||
|
xor eax, eax
|
||||||
|
|
||||||
|
.exit:
|
||||||
|
pop ecx ebx
|
||||||
|
|
||||||
|
leave
|
||||||
|
|
||||||
|
ret 4
|
||||||
|
|
||||||
|
thread_find_buff:
|
||||||
|
dd 0
|
||||||
|
|
||||||
|
event_add_mask:
|
||||||
|
xchg eax, dword [esp+4]
|
||||||
|
or dword [event_mask], eax
|
||||||
|
mcall 40, dword [event_mask]
|
||||||
|
xchg eax, dword [esp+4]
|
||||||
|
ret 4
|
||||||
|
|
||||||
|
event_mask:
|
||||||
|
dd 0
|
30
programs/system/kobra/trunk/kobra_st.s
Normal file
30
programs/system/kobra/trunk/kobra_st.s
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/***************************************************************************************************
|
||||||
|
* Copyright (C) Vasiliy Kosenko (vkos), 2009 *
|
||||||
|
* Kobra is free software: you can redistribute it and/or modify it under the terms of the GNU *
|
||||||
|
* General Public License as published by the Free Software Foundation, either version 3 *
|
||||||
|
* of the License, or (at your option) any later version. *
|
||||||
|
* *
|
||||||
|
* Kobra is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without *
|
||||||
|
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||||
|
* General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License along with Kobra. *
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>. *
|
||||||
|
***************************************************************************************************/
|
||||||
|
|
||||||
|
.global start, entry
|
||||||
|
.extern main
|
||||||
|
|
||||||
|
Start:
|
||||||
|
|
||||||
|
.byte 'M', 'E', 'N', 'U', 'E', 'T', '0', '1'
|
||||||
|
.long 0x1
|
||||||
|
.long begin
|
||||||
|
.long end
|
||||||
|
.long end+0x4000
|
||||||
|
.long end+0x4000
|
||||||
|
.long 0
|
||||||
|
.long 0
|
||||||
|
|
||||||
|
begin:
|
||||||
|
call main
|
Loading…
Reference in New Issue
Block a user