Gene Cumm
2009-Mar-31 02:31 UTC
[syslinux] [PATCH 1/1] CORE/cache: add cache priority parameter
From: Gene Cumm <gene.cumm at gmail.com> CORE/cache: add cache priority parameter; Passing in DX=0 forces the cache entry to stay at the least recently used spot. Any other value allows it to continue on previous behavior of most recently used position in the list. Change ldlinux.asm and extlinux.asm (the only 2 users of cache) to pass in DX=1. Push/Pop DX unless it's definitely safe to clobber. Signed-off-by: Gene Cumm <gene.cumm at gmail.com> --- This patch allows functions to request a sector as cache but it will only be available as cached until a cache miss. Inspired by a discussion in the last few days. diff --git a/core/cache.inc b/core/cache.inc index 5975557..b8eda9f 100644 --- a/core/cache.inc +++ b/core/cache.inc @@ -43,6 +43,8 @@ initcache: ; and if it is already there, return a pointer in GS:SI ; otherwise load it and return said pointer. ; +; DX Cache priority; 0 -> store as least recently used +; ; Assumes CS == DS. ; getcachesector: @@ -82,6 +84,10 @@ getcachesector: ; Update LRU, then compute buffer address TRACER 'H' + ; Skip LRU update if DX == 0 + and dx,dx ; Set ZF + jz .hit_no_lru + ; Remove from current position in the list mov bx,[si+cptr.prev] mov di,[si+cptr.next] @@ -95,6 +101,8 @@ getcachesector: mov [CachePtrs+cptr.prev],si mov word [si+cptr.next],CachePtrs +.hit_no_lru: + and ax,ax ; Clear ZF sub si,CachePtrs+cptr_size shl si,SECTOR_SHIFT-cptr_size_lg2 ; Buffer address diff --git a/core/extlinux.asm b/core/extlinux.asm index 9684c8a..59d460d 100644 --- a/core/extlinux.asm +++ b/core/extlinux.asm @@ -966,7 +966,10 @@ open_inode: add eax,edx pop edx and dx,SECTOR_SIZE-1 + push dx + mov dx,1 call getcachesector ; Get the group descriptor + pop dx add si,dx mov esi,[gs:si+bg_inode_table] ; Get inode table block # pop eax ; Get inode within group @@ -985,7 +988,10 @@ open_inode: and dx,SECTOR_SIZE-1 mov [bx+file_in_off],dx + push dx + mov dx,1 call getcachesector + pop dx add si,dx mov cx,EXT2_GOOD_OLD_INODE_SIZE >> 2 mov di,ThisInode @@ -1351,6 +1357,7 @@ linsector: push eax mov eax,[si+file_in_sec] mov bx,si + mov dx,1 call getcachesector ; Get inode add si,[bx+file_in_off] ; Get *our* inode pop eax @@ -1382,7 +1389,10 @@ linsector: mov ebp,[gs:si+bx] shl ebp,cl add eax,ebp + push dx + mov dx,1 call getcachesector + pop dx pop bx and bx,(SECTOR_SIZE >> 2)-1 shl bx,2 @@ -1400,7 +1410,10 @@ linsector: mov ebp,[gs:si+bx] shl ebp,cl add eax,ebp + push dx + mov dx,1 call getcachesector + pop dx pop bx and bx,(SECTOR_SIZE >> 2)-1 shl bx,2 @@ -1415,6 +1428,7 @@ linsector: mov ebp,[gs:si+bx] shl ebp,cl add eax,ebp + mov dx,1 call getcachesector pop bx and bx,(SECTOR_SIZE >> 2)-1 diff --git a/core/ldlinux.asm b/core/ldlinux.asm index b98cd92..9cbf428 100644 --- a/core/ldlinux.asm +++ b/core/ldlinux.asm @@ -1058,6 +1058,7 @@ search_dos_dir: .scansector: ; EAX <- directory sector to scan + mov dx,1 call getcachesector ; GS:SI now points to this sector @@ -1411,6 +1412,7 @@ readdir: and eax,eax jz .fail .fetch_cache: + mov dx,1 call getcachesector .move_current: add si,bx ; Resume last position in sector @@ -2025,7 +2027,11 @@ nextsector: ; getfatsector: add eax,[FAT] ; FAT starting address - jmp getcachesector + push dx + mov dx,1 + call getcachesector + pop dx + ret ; ----------------------------------------------------------------------------- ; Common modules
H. Peter Anvin
2009-Apr-01 00:55 UTC
[syslinux] [PATCH 1/1] CORE/cache: add cache priority parameter
Hi Gene, I have to admit having somewhat lost track of your work, just due to the sheer number of patches, and the forward-looking nature. Is there any way you could publish a git tree with your stuff in it that I can pull and look at? -hpa