Subversion Repositories Kolibri OS

Rev

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

Rev 1130 Rev 1213
Line 3... Line 3...
3
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2008. 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: 1130 $
8
$Revision: 1213 $
9
 
9
 
10
 
10
 
Line 1216... Line 1216...
1216
 
1216
 
1217
           mov eax, [access]
1217
           mov eax, [access]
1218
           and eax, SHM_OPEN_MASK
1218
           and eax, SHM_OPEN_MASK
Line 1219... Line 1219...
1219
           mov [action], eax
1219
           mov [action], eax
1220
 
1220
 
1221
           mov eax, [name]
1221
           mov ebx, [name]
1222
           test eax, eax
1222
           test ebx, ebx
Line 1223... Line 1223...
1223
           mov edx, E_PARAM
1223
           mov edx, E_PARAM
1224
           jz .exit
1224
           jz .fail
1225
 
1225
 
1226
           mov esi, [shmem_list.fd]
1226
           mov esi, [shmem_list.fd]
1227
align 4
1227
align 4
Line 1228... Line 1228...
1228
@@:
1228
@@:
1229
           cmp esi, shmem_list
1229
           cmp esi, shmem_list
1230
           je .not_found
1230
           je .not_found
1231
 
1231
 
Line 1232... Line 1232...
1232
           lea edx, [esi+SMEM.name] ; link , base, size
1232
           lea edx, [esi+SMEM.name] ; link , base, size
1233
           stdcall strncmp, edx, eax, 32
1233
           stdcall strncmp, edx, ebx, 32
Line 1240... Line 1240...
1240
.not_found:
1240
.not_found:
1241
           mov eax, [action]
1241
           mov eax, [action]
Line 1242... Line 1242...
1242
 
1242
 
1243
           cmp eax, SHM_OPEN
1243
           cmp eax, SHM_OPEN
1244
           mov edx, E_NOTFOUND
1244
           mov edx, E_NOTFOUND
Line 1245... Line 1245...
1245
           je .exit
1245
           je .fail
1246
 
1246
 
1247
           cmp eax, SHM_CREATE
1247
           cmp eax, SHM_CREATE
Line 1248... Line 1248...
1248
           mov edx, E_PARAM
1248
           mov edx, E_PARAM
1249
           je .create_shm
1249
           je .create_shm
Line 1250... Line 1250...
1250
 
1250
 
Line 1251... Line 1251...
1251
           cmp eax, SHM_OPEN_ALWAYS
1251
           cmp eax, SHM_OPEN_ALWAYS
1252
           jne .exit
1252
           jne .fail
1253
 
1253
 
Line 1254... Line 1254...
1254
.create_shm:
1254
.create_shm:
1255
 
1255
 
1256
           mov ecx, [size]
1256
           mov ecx, [size]
Line 1257... Line 1257...
1257
           test ecx, ecx
1257
           test ecx, ecx
1258
           jz .exit
1258
           jz .fail
1259
 
1259
 
1260
           add ecx, 4095
1260
           add ecx, 4095
1261
           and ecx, -4096
1261
           and ecx, -4096
1262
           mov [size], ecx
1262
           mov [size], ecx
Line 1263... Line 1263...
1263
 
1263
 
1264
           mov eax, SMEM.sizeof
1264
           mov eax, SMEM.sizeof
1265
           call malloc
1265
           call malloc
1266
           test eax, eax
1266
           test eax, eax
Line 1307... Line 1307...
1307
           cmp eax, SHM_OPEN
1307
           cmp eax, SHM_OPEN
1308
           mov edx, E_PARAM
1308
           mov edx, E_PARAM
1309
           je .create_map
1309
           je .create_map
Line 1310... Line 1310...
1310
 
1310
 
1311
           cmp eax, SHM_OPEN_ALWAYS
1311
           cmp eax, SHM_OPEN_ALWAYS
Line 1312... Line 1312...
1312
           jne .exit
1312
           jne .fail
Line 1313... Line 1313...
1313
 
1313
 
1314
.create_map:
1314
.create_map:
1315
 
1315
 
1316
           mov eax, [access]
1316
           mov eax, [access]
1317
           and eax, SHM_ACCESS_MASK
1317
           and eax, SHM_ACCESS_MASK
1318
           cmp eax, [esi+SMEM.access]
1318
           cmp eax, [esi+SMEM.access]
Line 1319... Line 1319...
1319
           mov [access], eax
1319
           mov [access], eax
1320
           mov edx, E_ACCESS
1320
           mov edx, E_ACCESS
1321
           ja .exit
1321
           ja .fail
1322
 
1322
 
Line 1323... Line 1323...
1323
           mov ebx, [CURRENT_TASK]
1323
           mov ebx, [CURRENT_TASK]
1324
           shl ebx, 5
1324
           shl ebx, 5
1325
           mov ebx, [CURRENT_TASK+ebx+4]
1325
           mov ebx, [CURRENT_TASK+ebx+4]
1326
           mov eax, SMAP.sizeof
1326
           mov eax, SMAP.sizeof
1327
 
1327
 
-
 
1328
           call create_kernel_object
-
 
1329
           test eax, eax
Line 1328... Line 1330...
1328
           call create_kernel_object
1330
           mov edi, eax
1329
           test eax, eax
1331
           mov edx, E_NOMEM
-
 
1332
           jz .fail
1330
           mov edi, eax
1333
 
1331
           mov edx, E_NOMEM
-
 
Line 1332... Line 1334...
1332
           jz .exit
1334
           inc [esi+SMEM.refcount]
1333
 
1335
 
1334
           mov [edi+SMAP.magic], 'SMAP'
1336
           mov [edi+SMAP.magic], 'SMAP'
1335
           mov [edi+SMAP.destroy], destroy_smap
1337
           mov [edi+SMAP.destroy], destroy_smap
1336
           mov [edi+SMAP.base], 0
1338
           mov [edi+SMAP.parent], esi
Line 1337... Line -...
1337
           mov [edi+SMAP.parent], 0
-
 
1338
 
1339
           mov [edi+SMAP.base], 0
1339
           stdcall user_alloc, [esi+SMEM.size]
-
 
Line 1340... Line 1340...
1340
           test eax, eax
1340
 
1341
           mov [mapped], eax
1341
           stdcall user_alloc, [esi+SMEM.size]
Line 1342... Line 1342...
1342
           mov edx, E_NOMEM
1342
           test eax, eax
Line 1369... Line 1369...
1369
           loop @B
1369
           loop @B
Line 1370... Line 1370...
1370
 
1370
 
Line 1371... Line 1371...
1371
           xor edx, edx
1371
           xor edx, edx
1372
 
1372
 
1373
           cmp [owner_access], 0
-
 
1374
           jne .exit
-
 
1375
 
1373
           cmp [owner_access], 0
-
 
1374
           jne .fail
-
 
1375
.exit:
1376
           mov edx, [size]
1376
           mov edx, [size]
Line 1377... Line 1377...
1377
.exit:
1377
.fail:
1378
           mov eax, [mapped]
1378
           mov eax, [mapped]
1379
 
1379
 
1380
           popfd
1380
           popfd
1381
           pop edi
1381
           pop edi
1382
           pop esi
-
 
1383
           pop ebx
1382
           pop esi
-
 
1383
           pop ebx
1384
           ret
1384
           ret
1385
 
1385
.cleanup:
1386
.cleanup:
1386
           mov [size], edx
Line 1387... Line 1387...
1387
           mov eax, esi
1387
           mov eax, esi
-
 
1388
           call free
1388
           call free
1389
           jmp .exit
1389
           jmp .exit
1390
 
1390
 
1391
.cleanup2:
1391
.cleanup2:
1392
           mov [size], edx