Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;  Copyright (C) Vasiliy Kosenko (vkos), 2009                                                    ;;
  3. ;;  Kobra is free software: you can redistribute it and/or modify it under the terms of the GNU   ;;
  4. ;;  General Public License as published by the Free Software Foundation, either version 3         ;;
  5. ;;  of the License, or (at your option) any later version.                                        ;;
  6. ;;                                                                                                ;;
  7. ;;  Kobra is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without    ;;
  8. ;;  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;
  9. ;;  General Public License for more details.                                                      ;;
  10. ;;                                                                                                ;;
  11. ;;  You should have received a copy of the GNU General Public License along with Kobra.           ;;
  12. ;;  If not, see <http://www.gnu.org/licenses/>.                                                   ;;
  13. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  14.  
  15. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  16. ;;  This is set of functions to work with Kobra daemon                                            ;;
  17. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  18.  
  19. define KOBRA_MESSAGE_MAX_LEN 0x100
  20.  
  21. define KOBRA_CMD_REGISTER       'R'
  22. define KOBRA_CMD_JOIN           'J'
  23. define KOBRA_CMD_UNJOIN         'U'
  24. define KOBRA_CMD_SEND           'S'
  25.  
  26. define KOBRA_MESSAGE_LAUNCH_STATE 1
  27.  
  28. kobra_register:
  29.         mov eax, kobra_message_area
  30.         mov byte [eax], KOBRA_CMD_REGISTER
  31.        
  32.         stdcall thread_find_by_name, kobra_thread_name
  33.        
  34.         test eax, eax
  35.         je .error
  36.        
  37.         mov dword [kobra_tid], eax                              ;; Save tid
  38.        
  39.         mov ecx, eax
  40.        
  41.         mcall 60, 2, , kobra_message_area, 1
  42.        
  43.         test eax, eax
  44.         je .return
  45.        
  46. .error:
  47.         inc eax
  48.        
  49. .return:
  50.         ret
  51.  
  52. ;; void kobra_send_message(char *group, void *message, int length);
  53. kobra_send_message:
  54.         push ebp
  55.         mov ebp, esp
  56.        
  57.         cld
  58.        
  59.         mov edi, kobra_message_area
  60.         mov al, KOBRA_CMD_SEND
  61.         stosb
  62.        
  63.         mov esi, dword [ebp+8]
  64.        
  65. .copy_group_cycle:
  66.         mov al, byte [esi]
  67.         test al, al
  68.         jz .copy_group_end
  69.         movsb
  70.         jmp .copy_group_cycle
  71.        
  72. .copy_group_end:
  73.        
  74. ;       xor al, al
  75.         stosb
  76.        
  77.         mov esi, dword [ebp+12]
  78.         mov ecx, dword [ebp+16]
  79.         rep movsb
  80.        
  81.         lea eax, [edi-kobra_message_area]
  82.        
  83.         mcall 60, 2, dword [kobra_tid], kobra_message_area, eax
  84.        
  85.         leave
  86.        
  87.         ret 12
  88.  
  89. kobra_tid:
  90.         dd 0
  91.  
  92. kobra_message_area:
  93.         rb KOBRA_MESSAGE_MAX_LEN
  94.  
  95. kobra_thread_name:
  96.         db "kobra", 0, 0, 0, 0, 0, 0
  97.