Newsgroups: comp.os.minix
Subject: Re: Allocate problem in kernel!
References: <86mkh6$poa$1@news.cybercity.dk>
Organization: Rochester Institute of Technology, Rochester, NY
From: aje9383@osfmail.isc.rit.edu (Andrew Erickson)
NNTP-Posting-Host: grace.isc.rit.edu
X-Original-NNTP-Posting-Host: grace.isc.rit.edu
Message-ID: <388f7c99@news.isc.rit.edu>
Date: 26 Jan 2000 18:00:41 -0500
X-Trace: 26 Jan 2000 18:00:41 -0500, grace.isc.rit.edu
Lines: 51
XPident: dav1456
X-Original-NNTP-Posting-Host: 129.21.4.100
XPident: Unknown
Path: news.adfa.oz.au!clarion.carno.net.au!news0.optus.net.au!news1.optus.net.au!optus!newsfeed.zip.com.au!newsfeed.berkeley.edu!logbridge.uoregon.edu!news.acsu.buffalo.edu!bingnews.binghamton.edu!news-nysernet-16.sprintlink.net!news.sprintlink.net!news.isc.rit.edu!aje9383
Xref: news.adfa.oz.au comp.os.minix:34624

In article <86mkh6$poa$1@news.cybercity.dk>,
Svend Meyland Nicolaisen <nicolaisen@my-deja.com> wrote:
>Does anyone know how to allocate memory in the kernel ??

As I understand it, kernel memory in Minix (Here, I'm using "kernel" to
include everything that's not a user process-the kernel proper, FS, MM,
and device drivers) must be either statically allocated (globals, local
variables declared static) or on the stack (other locals).  There is no
general dynamic memory allocator/deallocator along the lines of kmalloc
or malloc.

>The problem is that I would like to allocate memory for a specific
>dma-device. I'm trying to port a linux driver to minix, - in linux the
>kalloc function is used to allocate memory in the kernel. This function is
>not supported in minix. I'v tried to map the dma-device to memory with in
>the kernel by extending the stack-size. This is however not a good idear
>since the kernel becomes very large and there by making the bootloader fail.

What sort of a DMA device is this?  If it's a disk, you simply dump the
data in the buffer which FS gives you; if it's some special device, you
generally dump data directly into the user process (perhaps after going
through some sort of a buffer if dropping data is a bad thing).

It is probably best to allocate the buffer as a static array instead of
on the stack, as that helps avoid stack overruns if any one of a number
of impossible things were to happen.  Since the stack for the kernel is
put in a global array, this will not help your bootloader problems.  It
seems strange to me that you would need *that* much memory for a device
to DMA into, although I'm not doubting you on that.

>Im trying to ask for memory in the kernel free-mem pointer list but this is
>causing protection errors (i'm not doing i right..?) When listing the
>pointer-list there allso seems to be only to small chuncks off memory free ?
>(this is before the mm takes up all memory)

Ugh; that sounds like a difficult approach.  If I understand how things
work properly, MM maintains the free-pointer list; it doesn't "take up"
all the memory per se.  (I may be confused; I haven't studied that part
of Minix for quite awhile.)  If MM hasn't initialized it yet, you could
get *anything* for "free" memory.

At any rate, getting MM to manage some memory dyamically for the kernel
would be a rather interesting project, and could be used to good effect
for other things--most notably, the disk cache could be dynamically set
so as to use all unused memory.

>Best regards,
>Svend M.N & Uffe N

-- 
Andrew Erickson
