From owner-freebsd-drivers@FreeBSD.ORG Mon Jun 4 11:55:05 2007 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 43D2016A46C for ; Mon, 4 Jun 2007 11:55:05 +0000 (UTC) (envelope-from die.gestalt@gmail.com) Received: from py-out-1112.google.com (py-out-1112.google.com [64.233.166.181]) by mx1.freebsd.org (Postfix) with ESMTP id C17B313C46C for ; Mon, 4 Jun 2007 11:55:04 +0000 (UTC) (envelope-from die.gestalt@gmail.com) Received: by py-out-1112.google.com with SMTP id a29so2334941pyi for ; Mon, 04 Jun 2007 04:55:04 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=lXCTmSkmb2LE+NujmnAmOE429JlFCBkXeg+OT0oWo2ur+2augZDYIFHX/ZuLpvqPEE6unsBctqcYbOshalAoyttho46jJswU0MWALX8y1shexaWZsIXKVCp/kiFLQWDgYmgj8dM6mEUeupRrpLS0o+vPD343aY7o1oOmTNwUl8I= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=VVcH0SI/tI6SVwlh24Qf0b8vdTzVNThRAcQDR0UntZUV8ULiRk2eAm41n+5x8xVbnoh+1nKzmT1s9tqm7vQuH0PWKsKU5IAOtG3kmcB5gMY3JKRj1DKkHkJNzXKgBL/cxFM5NAnxnA9ypSMhqEBizAfTeTReeTdjCzKDl9JrEdc= Received: by 10.64.131.17 with SMTP id e17mr6707881qbd.1180958104022; Mon, 04 Jun 2007 04:55:04 -0700 (PDT) Received: by 10.64.181.10 with HTTP; Mon, 4 Jun 2007 04:55:03 -0700 (PDT) Message-ID: <5bf3e10d0706040455j2015a2dan685e7e80db66bd95@mail.gmail.com> Date: Mon, 4 Jun 2007 13:55:03 +0200 From: "Die Gestalt" To: freebsd-drivers@freebsd.org In-Reply-To: <5bf3e10d0706010709yab08f21s256cb894118d3bf4@mail.gmail.com> MIME-Version: 1.0 References: <5bf3e10d0705150724q3f0fd25fq89094bd02d8f9d29@mail.gmail.com> <86veetgnk4.fsf@dwp.des.no> <5bf3e10d0705210744s119d1c5cpc20ab1036e9f98ff@mail.gmail.com> <5bf3e10d0705221130t222b80b5w64a4e446b04d6029@mail.gmail.com> <863b1nvqqa.fsf@dwp.des.no> <5bf3e10d0705230314w3038a532uf0d8c0ed18a5d05f@mail.gmail.com> <5bf3e10d0705240839x17792a96hf17e6eebfa5a83da@mail.gmail.com> <5bf3e10d0705241345t11e739we0b896bab868fec6@mail.gmail.com> <5bf3e10d0706010709yab08f21s256cb894118d3bf4@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: Re: Generic int 13h driver X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jun 2007 11:55:05 -0000 Problem understood. What happens is that for reading the BIOS writes at the physical address and not the virtual address, and the virtual translation doesn't occur in this case since the write doesn't come from the CPU. I don't get why it works with writing though, maybe the BIOS uses DMA only for reading? My buffer is therefore never written but physical memory get happilly overwritten (omg!!). Unfortunately I cannot manage to allocate physical memory below 1 MB by the time I load my driver. bus_dmamem_alloc fails as well as contigalloc (on which bus_dmamem_alloc is based anyways). Any clue? Should I add some code in the booting process to reserve few chunks below 1 MB for me? Is the dark side stronger? Another question, is there anyway I can know if the BIOS is using DMA or not? Obviously in one case I need to give a physical address and the other case virtual address. When this is fixed I will have a fully working int13h driver. w00t. On 6/1/07, Die Gestalt wrote: > > Hi me again... ;) > > Well now I correctly hook the interrupts, they are correctly reflected > back to the BIOS and I can write to the disk without a problem. When DMA is > on, however, reading fails (it works when DMA is off in the BIOS). This is > obviously a DMA problem and for some reason the machine does not read the > correct page value. > > The problem is that the Virtual 8086 monitor makes an "invalidate page" > call when the operation is finished and my buffers are loaded into a DMA > mapping and I do the proper pre/post synchronization, I've even tried with > reversed sync in case I got it wrong. > > I think the problem is a lack of understanding on my side about how DMA > works in FreeBSD. What I do is I have a parent tag and two child tags (one > for reading the other for writing), I do : > > bus_dma_tag_create -> bus_dmamap_create > > Later I do contigmalloc of my buffer and I load this buffer with bus_dmamap_load. > I do bus_dmamap_sync before and after the call the BIOS. > > The writes are succesfull but the read buffer is left untouched. What do I > do wrong? What is the exact use of the callback? > > Thanks for any hint. > >