Subversion Repositories Kolibri OS

Rev

Rev 4531 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4531 Rev 5051
Line 351... Line 351...
351
        mov     [last_reports+2*4], eax
351
        mov     [last_reports+2*4], eax
352
        add     eax, hid_data.first_collection - hid_data.feature.first_report
352
        add     eax, hid_data.first_collection - hid_data.feature.first_report
353
        mov     [last_collection], eax
353
        mov     [last_collection], eax
354
; 1b. Allocate state of global items.
354
; 1b. Allocate state of global items.
355
        movi    eax, sizeof.global_items
355
        movi    eax, sizeof.global_items
356
        call    Kmalloc
356
        invoke  Kmalloc
357
        test    eax, eax
357
        test    eax, eax
358
        jz      .memory_error
358
        jz      .memory_error
359
; 1c. Zero-initialize it and move pointer to edi.
359
; 1c. Zero-initialize it and move pointer to edi.
360
        push    eax
360
        push    eax
361
        xchg    eax, edi
361
        xchg    eax, edi
Line 371... Line 371...
371
        mov     eax, [usage_list]
371
        mov     eax, [usage_list]
372
@@:
372
@@:
373
        test    eax, eax
373
        test    eax, eax
374
        jz      @f
374
        jz      @f
375
        push    [eax+usage_list_item.next]
375
        push    [eax+usage_list_item.next]
376
        call    Kfree
376
        invoke  Kfree
377
        pop     eax
377
        pop     eax
378
        jmp     @b
378
        jmp     @b
379
@@:
379
@@:
380
        lea     ecx, [usage_list]
380
        lea     ecx, [usage_list]
381
        mov     [usage_tail], ecx
381
        mov     [usage_tail], ecx
Line 494... Line 494...
494
; Note: it is incorrect but theoretically possible that some fields were
494
; Note: it is incorrect but theoretically possible that some fields were
495
; already allocated in report without ID; if so, abort processing with error.
495
; already allocated in report without ID; if so, abort processing with error.
496
        cmp     [ebx+report_set.data], 0
496
        cmp     [ebx+report_set.data], 0
497
        jnz     .invalid_report
497
        jnz     .invalid_report
498
        mov     eax, 256*4
498
        mov     eax, 256*4
499
        call    Kmalloc
499
        invoke  Kmalloc
500
        test    eax, eax
500
        test    eax, eax
501
        jz      .memory_error
501
        jz      .memory_error
502
        mov     [ebx+report_set.data], eax
502
        mov     [ebx+report_set.data], eax
503
        inc     [ebx+report_set.numbered]
503
        inc     [ebx+report_set.numbered]
504
        push    edi
504
        push    edi
Line 519... Line 519...
519
; 7a. Check whether the report has been allocated.
519
; 7a. Check whether the report has been allocated.
520
        cmp     dword [ebx], 0
520
        cmp     dword [ebx], 0
521
        jnz     .report_allocated
521
        jnz     .report_allocated
522
; 7b. Allocate.
522
; 7b. Allocate.
523
        movi    eax, sizeof.report
523
        movi    eax, sizeof.report
524
        call    Kmalloc
524
        invoke  Kmalloc
525
        test    eax, eax
525
        test    eax, eax
526
        jz      .memory_error
526
        jz      .memory_error
527
; 7c. Initialize.
527
; 7c. Initialize.
528
        xor     edx, edx
528
        xor     edx, edx
529
        lea     ecx, [eax+report.first_field]
529
        lea     ecx, [eax+report.first_field]
Line 566... Line 566...
566
        jnz     @f
566
        jnz     @f
567
        lea     eax, [eax+edx*4]
567
        lea     eax, [eax+edx*4]
568
        mov     edx, [num_usage_ranges]
568
        mov     edx, [num_usage_ranges]
569
        lea     eax, [eax+edx*sizeof.usage_range+4]
569
        lea     eax, [eax+edx*sizeof.usage_range+4]
570
@@:
570
@@:
571
        call    Kmalloc
571
        invoke  Kmalloc
572
        pop     edx
572
        pop     edx
573
        test    eax, eax
573
        test    eax, eax
574
        jz      .memory_error
574
        jz      .memory_error
575
; 11. Update report data.
575
; 11. Update report data.
576
; Field offset is the current report size;
576
; Field offset is the current report size;
Line 686... Line 686...
686
.collection:
686
.collection:
687
; Actions are quite straightforward:
687
; Actions are quite straightforward:
688
; allocate, zero-initialize, update parent, if there is one,
688
; allocate, zero-initialize, update parent, if there is one,
689
; make it current.
689
; make it current.
690
        movi    eax, sizeof.collection
690
        movi    eax, sizeof.collection
691
        call    Kmalloc
691
        invoke  Kmalloc
692
        test    eax, eax
692
        test    eax, eax
693
        jz      .memory_error
693
        jz      .memory_error
694
        push    eax edi
694
        push    eax edi
695
        movi    ecx, sizeof.collection / 4
695
        movi    ecx, sizeof.collection / 4
696
        xchg    edi, eax
696
        xchg    edi, eax
Line 815... Line 815...
815
; Two special global items: Push/Pop.
815
; Two special global items: Push/Pop.
816
.push:
816
.push:
817
; For Push, allocate new global_items structure,
817
; For Push, allocate new global_items structure,
818
; initialize from the current one and make it current.
818
; initialize from the current one and make it current.
819
        movi    eax, sizeof.global_items
819
        movi    eax, sizeof.global_items
820
        call    Kmalloc
820
        invoke  Kmalloc
821
        test    eax, eax
821
        test    eax, eax
822
        jz      .memory_error
822
        jz      .memory_error
823
        push    esi eax
823
        push    esi eax
824
        movi    ecx, sizeof.global_items / 4
824
        movi    ecx, sizeof.global_items / 4
825
        mov     esi, edi
825
        mov     esi, edi
Line 833... Line 833...
833
        mov     eax, [edi+global_items.next]
833
        mov     eax, [edi+global_items.next]
834
        test    eax, eax
834
        test    eax, eax
835
        jz      .invalid_report
835
        jz      .invalid_report
836
        push    eax
836
        push    eax
837
        xchg    eax, edi
837
        xchg    eax, edi
838
        call    Kfree
838
        invoke  Kfree
839
        pop     edi
839
        pop     edi
840
        jmp     .item_parsed
840
        jmp     .item_parsed
841
; -------------------------------- Local items --------------------------------
841
; -------------------------------- Local items --------------------------------
842
.parse_local:
842
.parse_local:
843
        cmp     eax, .num_local_items
843
        cmp     eax, .num_local_items
Line 860... Line 860...
860
; Add new range with start = item data and length = 1.
860
; Add new range with start = item data and length = 1.
861
        mov     [usage_minimum], ebx
861
        mov     [usage_minimum], ebx
862
        push    1
862
        push    1
863
.new_usage:
863
.new_usage:
864
        movi    eax, sizeof.usage_list_item
864
        movi    eax, sizeof.usage_list_item
865
        call    Kmalloc
865
        invoke  Kmalloc
866
        pop     edx
866
        pop     edx
867
        test    eax, eax
867
        test    eax, eax
868
        jz      .memory_error
868
        jz      .memory_error
869
        inc     [num_usage_ranges]
869
        inc     [num_usage_ranges]
870
        mov     ecx, [usage_minimum]
870
        mov     ecx, [usage_minimum]
Line 910... Line 910...
910
        cmp     [delimiter_depth], 0
910
        cmp     [delimiter_depth], 0
911
        jnz     .invalid_report
911
        jnz     .invalid_report
912
        inc     [delimiter_depth]
912
        inc     [delimiter_depth]
913
        push    esi
913
        push    esi
914
        mov     esi, delimiter_note
914
        mov     esi, delimiter_note
915
        call    SysMsgBoardStr
915
        invoke  SysMsgBoardStr
916
        pop     esi
916
        pop     esi
917
        jmp     .item_parsed
917
        jmp     .item_parsed
918
.delimiter.close:
918
.delimiter.close:
919
; Delimiter(Closed).
919
; Delimiter(Closed).
920
; Store that we are not inside Delimiter() anymore.
920
; Store that we are not inside Delimiter() anymore.
Line 952... Line 952...
952
        inc     [report_ok]
952
        inc     [report_ok]
953
        jmp     .end
953
        jmp     .end
954
.memory_error:
954
.memory_error:
955
        mov     esi, nomemory_msg
955
        mov     esi, nomemory_msg
956
.end_str:
956
.end_str:
957
        call    SysMsgBoardStr
957
        invoke  SysMsgBoardStr
958
.end:
958
.end:
959
; Free all global_items structures.
959
; Free all global_items structures.
960
        test    edi, edi
960
        test    edi, edi
961
        jz      @f
961
        jz      @f
962
        push    [edi+global_items.next]
962
        push    [edi+global_items.next]
963
        xchg    eax, edi
963
        xchg    eax, edi
964
        call    Kfree
964
        invoke  Kfree
965
        pop     edi
965
        pop     edi
966
        jmp     .end
966
        jmp     .end
967
@@:
967
@@:
968
; Free the last Usage list, if any.
968
; Free the last Usage list, if any.
969
        mov     eax, [usage_list]
969
        mov     eax, [usage_list]
970
@@:
970
@@:
971
        test    eax, eax
971
        test    eax, eax
972
        jz      @f
972
        jz      @f
973
        push    [eax+usage_list_item.next]
973
        push    [eax+usage_list_item.next]
974
        call    Kfree
974
        invoke  Kfree
975
        pop     eax
975
        pop     eax
976
        jmp     @b
976
        jmp     @b
977
@@:
977
@@:
978
}
978
}
Line 1114... Line 1114...
1114
        test    eax, eax
1114
        test    eax, eax
1115
        jnz     @f
1115
        jnz     @f
1116
        mov     eax, [esi+collection.parent]
1116
        mov     eax, [esi+collection.parent]
1117
@@:
1117
@@:
1118
        xchg    eax, esi
1118
        xchg    eax, esi
1119
        call    Kfree
1119
        invoke  Kfree
1120
        jmp     .free_collections
1120
        jmp     .free_collections
1121
.collections_done:
1121
.collections_done:
1122
; 3. Free all three report sets.
1122
; 3. Free all three report sets.
1123
        push    3
1123
        push    3
1124
        lea     esi, [ebx+hid_data.input]
1124
        lea     esi, [ebx+hid_data.input]
Line 1134... Line 1134...
1134
        mov     eax, [edi+report.first_field]
1134
        mov     eax, [edi+report.first_field]
1135
.field_loop:
1135
.field_loop:
1136
        test    eax, eax
1136
        test    eax, eax
1137
        jz      .field_done
1137
        jz      .field_done
1138
        push    [eax+report_field_group.next]
1138
        push    [eax+report_field_group.next]
1139
        call    Kfree
1139
        invoke  Kfree
1140
        pop     eax
1140
        pop     eax
1141
        jmp     .field_loop
1141
        jmp     .field_loop
1142
.field_done:
1142
.field_done:
1143
        mov     eax, [edi+report.next]
1143
        mov     eax, [edi+report.next]
1144
        xchg    eax, edi
1144
        xchg    eax, edi
1145
        call    Kfree
1145
        invoke  Kfree
1146
        jmp     .report_loop
1146
        jmp     .report_loop
1147
.report_done:
1147
.report_done:
1148
        cmp     [esi+report_set.numbered], 0
1148
        cmp     [esi+report_set.numbered], 0
1149
        jz      @f
1149
        jz      @f
1150
        mov     eax, [esi+report_set.data]
1150
        mov     eax, [esi+report_set.data]
1151
        call    Kfree
1151
        invoke  Kfree
1152
@@:
1152
@@:
1153
        add     esi, sizeof.report_set
1153
        add     esi, sizeof.report_set
1154
        dec     dword [esp]
1154
        dec     dword [esp]
1155
        jnz     .report_set_loop
1155
        jnz     .report_set_loop
1156
        pop     eax
1156
        pop     eax