1 ; -*- fundamental -*- ---------------------------------------------------
3 ; Copyright 2004 H. Peter Anvin - All Rights Reserved
5 ; This program is free software; you can redistribute it and/or modify
6 ; it under the terms of the GNU General Public License as published by
7 ; the Free Software Foundation, Inc., 53 Temple Place Ste 330,
8 ; Boston MA 02111-1307, USA; either version 2 of the License, or
9 ; (at your option) any later version; incorporated herein by reference.
11 ; -----------------------------------------------------------------------
12 ; $Id: cache.inc,v 1.3 2005/01/25 07:15:21 hpa Exp $
16 ; initcache: Initialize the cache data structures
19 xor eax,eax ; We don't care about sector 0
21 mov cx,65536/SECTOR_SIZE
27 ; getcachesector: Check for a particular sector (EAX) in the sector cache,
28 ; and if it is already there, return a pointer in GS:SI
29 ; otherwise load it and return said pointer.
37 mov si,CachePtrs ; Sector cache pointers
38 mov cx,65536/SECTOR_SIZE
47 ; Need to load it. Highly inefficient cache replacement
48 ; algorithm: Least Recently Written (LRW)
53 mov bx,[NextCacheSlot]
55 and bx,(1 << (16-SECTOR_SHIFT))-1
56 mov [NextCacheSlot],bx
58 mov [CachePtrs+bx],eax
73 .hit: ; We have it; get the pointer
82 CachePtrs resd 65536/SECTOR_SIZE ; Cached sector pointers
83 NextCacheSlot resw 1 ; Next cache slot to occupy