home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / unix / internal / 2149 < prev    next >
Encoding:
Internet Message Format  |  1993-01-22  |  2.5 KB

  1. Xref: sparky comp.unix.internals:2149 comp.unix.sys5.r4:1355
  2. Newsgroups: comp.unix.internals,comp.unix.sys5.r4
  3. Path: sparky!uunet!dsiinc!bwong
  4. From: bwong@dsiinc.com (Bruce F. Wong)
  5. Subject: Re: kernel memory allocation with alignment
  6. Message-ID: <1993Jan20.222252.43@dsiinc.com>
  7. Organization: Distributed Systems International, Inc.
  8. Date: Wed, 20 Jan 1993 22:22:52 GMT
  9. Lines: 50
  10.  
  11. Greetings,
  12.  
  13. A few weeks ago I posted the following:
  14.  
  15. >I'm writing a streams device driver for 386 UNIX SVR4 and I need 512
  16. >bytes of DMAable memory that is aligned to a 512 byte boundary (i.e.
  17. >the starting address is a multiple of 512).  How is this done ?  None
  18. >of the kernel memory allocators take an alignment argument.  Please
  19. >send all responses via e-mail and I will post a summary if I get
  20. >enough useful information.  Thanks.
  21.  
  22. This article contains the summary of replys and also what I plan to
  23. do.
  24.  
  25. Most of the suggestions were like the following:
  26.  
  27. >From: uunet!westford.ccur.com!zimmermk (Karl Zimmerman)
  28. >    allocate 1024 bytes.  Somewhere in there are 512 bytes aligned to
  29. >a 512-byte boundary.   To find it, take the returned pointer, add 511, and
  30. >mask off the least-significant 9 bits.
  31.  
  32. The suggestion that sent me in the direction of the solution I plan to
  33. use is:
  34.  
  35. >From: uunet!gcx1.ssd.csd.harris.com!donh (Don Holzworth)
  36. >If you are  going to get data from a device, you are probably going
  37. >to want to use allocb. If allocb doesn't give you the proberly aligned
  38. >memory, specify 512 bytes more than you need and set the message block
  39. >pointer to the aligned address. I think that you actually do get
  40. >the data aligned on a 1K boundary, though. You could run a few
  41. >tests to see.
  42.  
  43. I ran some tests on ESIX 4.0.3 and confirmed that allocb will return
  44. space that is aligned according to its size (I tried 256, 512, 1K, 2K,
  45. and 4K).  The allocb(D3DK) manual entry doesn't mention this.  It also
  46. doesn't mention if the buffer is DMAable (i.e. my bus master network
  47. controller card can access the buffer if I pass it the physical
  48. address of the buffer).  I'm assuming that they are DMAable based on
  49. the last paragraph in Intro(D2DK):
  50.  
  51.    "Drivers do no have to worry about making kernel buffers
  52.     addressable to their DMA controllers.  The kernel will make sure
  53.     that any kernel buffer addresses passed to a driver entry point
  54.     will be addressable by the driver's hardware."
  55.  
  56. Thank you for the suggestions.
  57. -- 
  58. Bruce F. Wong               Distributed Systems International, Inc.
  59. bwong@dsiinc.com           531 West Roosevelt Road, Suite 2
  60. Tel:708-665-4639 Fax:708-665-4706  Wheaton, IL 60187-5057
  61.