Subversion Repositories Kolibri OS

Rev

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

Rev 940 Rev 943
Line 3... Line 3...
3
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 7... Line 7...
7
 
7
 
Line 8... Line 8...
8
$Revision: 940 $
8
$Revision: 943 $
9
 
9
 
10
 
10
 
Line 1150... Line 1150...
1150
           cli
1150
           cli
Line 1151... Line 1151...
1151
 
1151
 
1152
           push ebx
1152
           push ebx
Line 1153... Line 1153...
1153
           mov ebx, eax
1153
           mov ebx, eax
1154
 
1154
 
1155
           mov eax, [eax+SHMAP.base]
1155
           mov eax, [eax+SMAP.base]
Line 1156... Line 1156...
1156
           test eax, eax
1156
           test eax, eax
1157
           jz @F
1157
           jz @F
1158
 
1158
 
1159
           stdcall user_free, eax
1159
           stdcall user_free, eax
1160
@@:
1160
@@:
Line 1161... Line 1161...
1161
           mov eax, [ebx+SHMAP.parent]
1161
           mov eax, [ebx+SMAP.parent]
1162
           test eax, eax
1162
           test eax, eax
1163
           jz @F
1163
           jz @F
1164
 
1164
 
Line 1165... Line 1165...
1165
           lock dec [eax+SHMEM.refcount]
1165
           lock dec [eax+SMEM.refcount]
Line 1219... Line 1219...
1219
align 4
1219
align 4
1220
@@:
1220
@@:
1221
           cmp esi, shmem_list
1221
           cmp esi, shmem_list
1222
           je .not_found
1222
           je .not_found
Line 1223... Line 1223...
1223
 
1223
 
1224
           lea edx, [esi+SHMEM.name] ; link , base, size
1224
           lea edx, [esi+SMEM.name] ; link , base, size
1225
           stdcall strncmp, edx, eax, 32
1225
           stdcall strncmp, edx, eax, 32
1226
           test eax, eax
1226
           test eax, eax
Line 1227... Line 1227...
1227
           je .found
1227
           je .found
1228
 
1228
 
Line 1229... Line 1229...
1229
           mov esi, [esi+SHMEM.fd]
1229
           mov esi, [esi+SMEM.fd]
1230
           jmp @B
1230
           jmp @B
Line 1251... Line 1251...
1251
 
1251
 
1252
           add ecx, 4095
1252
           add ecx, 4095
1253
           and ecx, -4096
1253
           and ecx, -4096
Line 1254... Line 1254...
1254
           mov [size], ecx
1254
           mov [size], ecx
1255
 
1255
 
1256
           mov eax, SHMEM.sizeof
1256
           mov eax, SMEM.sizeof
1257
           call malloc
1257
           call malloc
1258
           test eax, eax
1258
           test eax, eax
1259
           mov esi, eax
1259
           mov esi, eax
Line 1268... Line 1268...
1268
 
1268
 
1269
           mov ecx, [size]
1269
           mov ecx, [size]
1270
           mov edx, [access]
1270
           mov edx, [access]
Line 1271... Line 1271...
1271
           and edx, SHM_ACCESS_MASK
1271
           and edx, SHM_ACCESS_MASK
1272
 
1272
 
1273
           mov [esi+SHMEM.base], eax
1273
           mov [esi+SMEM.base], eax
1274
           mov [esi+SHMEM.size], ecx
1274
           mov [esi+SMEM.size], ecx
1275
           mov [esi+SHMEM.access], edx
1275
           mov [esi+SMEM.access], edx
Line 1276... Line 1276...
1276
           mov [esi+SHMEM.refcount], 0
1276
           mov [esi+SMEM.refcount], 0
1277
           mov [esi+SHMEM.name+28], 0
1277
           mov [esi+SMEM.name+28], 0
Line 1278... Line 1278...
1278
 
1278
 
1279
           lea eax, [esi+SHMEM.name]
1279
           lea eax, [esi+SMEM.name]
1280
           stdcall strncpy, eax, [name], 31
1280
           stdcall strncpy, eax, [name], 31
Line 1281... Line 1281...
1281
 
1281
 
1282
           mov eax, [shmem_list.fd]
1282
           mov eax, [shmem_list.fd]
Line 1283... Line 1283...
1283
           mov [esi+SHMEM.bk], shmem_list
1283
           mov [esi+SMEM.bk], shmem_list
1284
           mov [esi+SHMEM.fd], eax
1284
           mov [esi+SMEM.fd], eax
Line 1305... Line 1305...
1305
 
1305
 
Line 1306... Line 1306...
1306
.create_map:
1306
.create_map:
1307
 
1307
 
1308
           mov eax, [access]
1308
           mov eax, [access]
1309
           and eax, SHM_ACCESS_MASK
1309
           and eax, SHM_ACCESS_MASK
1310
           cmp eax, [esi+SHMEM.access]
1310
           cmp eax, [esi+SMEM.access]
1311
           mov [access], eax
1311
           mov [access], eax
Line 1312... Line 1312...
1312
           mov edx, E_ACCESS
1312
           mov edx, E_ACCESS
1313
           ja .exit
1313
           ja .exit
1314
 
1314
 
1315
           mov ebx, [CURRENT_TASK]
1315
           mov ebx, [CURRENT_TASK]
Line 1316... Line 1316...
1316
           shl ebx, 5
1316
           shl ebx, 5
1317
           mov ebx, [CURRENT_TASK+ebx+4]
1317
           mov ebx, [CURRENT_TASK+ebx+4]
1318
           mov eax, SHMAP.sizeof
1318
           mov eax, SMAP.sizeof
1319
 
1319
 
1320
           call create_kernel_object
1320
           call create_kernel_object
Line 1321... Line 1321...
1321
           test eax, eax
1321
           test eax, eax
1322
           mov edi, eax
1322
           mov edi, eax
1323
           mov edx, E_NOMEM
1323
           mov edx, E_NOMEM
1324
           jz .exit
1324
           jz .exit
Line 1325... Line 1325...
1325
 
1325
 
1326
           mov [edi+SHMAP.magic], 'SMEM'
1326
           mov [edi+SMAP.magic], 'SMAP'
1327
           mov [edi+SHMAP.destroy], destroy_smap
1327
           mov [edi+SMAP.destroy], destroy_smap
1328
           mov [edi+SHMAP.base], 0
1328
           mov [edi+SMAP.base], 0
1329
           mov [edi+SHMAP.parent], 0
1329
           mov [edi+SMAP.parent], 0
Line 1330... Line 1330...
1330
 
1330
 
1331
           stdcall user_alloc, [esi+SHMEM.size]
1331
           stdcall user_alloc, [esi+SMEM.size]
1332
           test eax, eax
1332
           test eax, eax
Line 1333... Line 1333...
1333
           mov [mapped], eax
1333
           mov [mapped], eax
1334
           mov edx, E_NOMEM
1334
           mov edx, E_NOMEM
Line 1335... Line 1335...
1335
           jz .cleanup2
1335
           jz .cleanup2
1336
 
1336
 
Line 1337... Line 1337...
1337
           lock inc [esi+SHMEM.refcount]
1337
           lock inc [esi+SMEM.refcount]
1338
           mov [edi+SHMAP.base], eax
1338
           mov [edi+SMAP.base], eax
1339
           mov [edi+SHMAP.parent], esi
1339
           mov [edi+SMAP.parent], esi
1340
 
1340
 
Line 1341... Line 1341...
1341
           mov ecx, [esi+SHMEM.size]
1341
           mov ecx, [esi+SMEM.size]
Line 1383... Line 1383...
1383
.cleanup2:
1383
.cleanup2:
1384
           mov eax, edi
1384
           mov eax, edi
1385
           call destroy_smap
1385
           call destroy_smap
1386
           jmp .exit
1386
           jmp .exit
1387
endp
1387
endp
-
 
1388
 
-
 
1389
align 4
-
 
1390
proc shmem_close stdcall, name:dword
-
 
1391
 
-
 
1392
           mov eax, [name]
-
 
1393
           test eax, eax
-
 
1394
           jz .fail
-
 
1395
 
-
 
1396
           push esi
-
 
1397
           push edi
-
 
1398
 
-
 
1399
           mov esi, [current_slot]
-
 
1400
           add esi, APP_OBJ_OFFSET
-
 
1401
.next:
-
 
1402
           mov eax, [esi+APPOBJ.fd]
-
 
1403
           test eax, eax
-
 
1404
           jz @F
-
 
1405
 
-
 
1406
           cmp eax, esi
-
 
1407
           mov esi, eax
-
 
1408
           je @F
-
 
1409
 
-
 
1410
           cmp [eax+SMAP.magic], 'SMAP'
-
 
1411
           jne .next
-
 
1412
 
-
 
1413
           mov edi, [eax+SMAP.parent]
-
 
1414
           test edi, edi
-
 
1415
           jz .next
-
 
1416
 
-
 
1417
           lea eax, [edi+SMEM.name]
-
 
1418
           stdcall strncmp, [name], edi, 32
-
 
1419
           test eax, eax
-
 
1420
           jne .next
-
 
1421
 
-
 
1422
           call [esi+APPOBJ.destroy]
-
 
1423
@@:
-
 
1424
           pop edi
-
 
1425
           pop esi
-
 
1426
.fail:
-
 
1427
           ret
-
 
1428
endp